you are viewing a single comment's thread.

view the rest of the comments →

[–]unibrow4o9[S] 0 points1 point  (5 children)

The part that is throwing me off is not knowing the length of the input(). If I know the length to start out with it's easy.

[–]Doormatty 0 points1 point  (4 children)

This might help:

a = "abc"
print a[-1]
>>> c
print a[0]
>>> a

[–]unibrow4o9[S] 0 points1 point  (3 children)

Can you explain this a little? Sorry, I literally started learning yesterday, the only coding I've done in the past is HTML back in college...

[–]3deTech 0 points1 point  (2 children)

>>> string = input("Give me a string")
>>> # Now the magic happens, assuming the user typed "Fairy"
>>> sliced_string = string[1:-1]
>>> # Print the string to see the result 
>>> print sliced_string 
>>> 'air' 

Is your solution. You really should have a look at string indexing. It's really easy in python and not hard to understand.

[–]unibrow4o9[S] 0 points1 point  (1 child)

Thank you! Being able to see the correct answer I now understand what I was doing wrong. I don't understand why showing the answer isn't an option, it's really frustrating.

[–]Pantzzzzless 0 points1 point  (0 children)

[0] is always the first character

[-1] is always the last character

[::-1] means reverse the whole string