Answers for "indexing in python example"

2

index in python

#index with eval()
k=eval(input("enter the list"))
for i in range(len(k)):
    print(k[i],"-->forward index",i,"backward index",-(len(k)-i))
#output
enter the list[1,9,5,7]
1 --> forward index 0 backward index -4
9 --> forward index 1 backward index -3
5 --> forward index 2 backward index -2
7 --> forward index 3 backward index -1
Posted by: Guest on December-20-2021
0

python indexing

>>> word = 'Python'
>>> word[0]  # character in position 0
'P'
>>> word[5]  # character in position 5
'n'
Posted by: Guest on January-15-2022

Python Answers by Framework

Browse Popular Code Answers by Language