Python - can't understand this reverse program -
this code, main goal of programme print message backwards
message = 'here example' translated = '' = len(message) - 1 while >= 0: translated = translated + message[i] = - 1 print(translated) what can't understand 3rd line, message contains 18 characters 'i' subtracts 1 it's 17, when run programme every symbol there, 5th line prints out message (still 1 character less) , nil missing, can explain why there?i know can 2 lines this
message = 'here example' print(message[::-1]) but want understand longer program.
indices in languages start 0, lastly character index length - 1
python reverse
No comments:
Post a Comment