Dec-22-2018, 05:41 PM
Hey!
I am trying to do the following:
1/user inputs a name e.g. "John".
2/user gets returned with the last character of the string e.g. "n".
Where I am so far:
I get IndexError: string index out of range
However, this works (see line 3):
Thanks!
I am trying to do the following:
1/user inputs a name e.g. "John".
2/user gets returned with the last character of the string e.g. "n".
Where I am so far:
name = input("provide an example of name: ") indexOfName = len(name) lastLetterofName = name[indexOfName] print(lastLetterofName)This does not work.
I get IndexError: string index out of range
However, this works (see line 3):
name = input("provide an example of name: ") indexOfName = len(name) lastLetterofName = name[indexOfName - 1] print(lastLetterofName)Any idea what I got wrong?
Thanks!