Given String 1="Exam 2021".Give output of string1[-1::-1]
Answers
Answer:
hello
Explanation:
String1="Exam2021" # here u have assigned the value of string1
String1[-1::-1] #this statement is using the concept of indexing.
" [-1::-1] means the start value should be -1,stop value is not mentioned that means it will be till the end from wherever it has started and step value is -1 that means we have to move in the opposite direction of the start value "
now applying index:
character - forward indexing - reverse indexing
E - 0 - (-8)
x - 1 - (-7)
a - 2 - (-6)
m - 3 - (-5)
2 - 4 - (-4)
0 - 5 - (-3)
2 - 6 - (-2)
1 - 7 - (-1)
_______________________________________________________
so the output is:
1202maxE
________________________________________________