This might be a challenge: I need some help with slicing a raw_input
I am new to programming and have learned recently how to slice.
I am practicing my writing my own code similar to pyg latin except by taking the inputted word in raw_input I need to check the last character and I dont know how to index an unknown length string.
....the string "paper" is entered
I need my code to identify the last character of the string
I thought of only two solutions
1. write a bajillion if/elif statements based
if len(word)<4 and len(word)<6
then i would index the last character as word
this would give me the letter "r" in paper
this is however long and tedious and could be never ending unless i figure out how to write a code with count statements and I could do this once. but I'm new, like i said, and have a lot of difficulty using count statements as is...never mind something complicated
2. something like slicing word[2:] which would print out the characters second through the end
except im looking for just the end
is there anything like the function word[last_character]
I'd really appreciate anyone's help
I'm doing this for fun and just some practice getting the hang of programming.
You can use negative indexes. The index [-1] refers to the last element of a sequence:-Mek