I'm currently attempting the this problem on codeacademy. The problem is I don't know how to move letters in a string.
The attempt I made was this
oword = raw_input('enter a english word') if len(oword) > 0 and oword.isalpha: step_one_new_word = (oword + oword) - oword
(couldn't tab so I did 4 spaces)
I was thinking that python had the strings in arrays. I'm not sure if that is the problem or if the "-" is. I need to get rid the that first letter. However I also need to move it to the end first.
I did find this answer and it seemed like it worked except I don't understand how. As you know in programming it's not like school. School they just teach you this is what you do. You do it on the test and your fine. Programming you need to know how and why it works or you'll never do anything.
Of course then I went and found this to explain substr but it still doesn't make sense.
He says this:
>>> x = "Hello World!" >>> x[2:] 'llo World!' >>> x[:2] 'He' >>> x[:-2] 'Hello Worl' >>> x[-2:] 'd!'
Does the side of the number determine if it returns everything but that part or just that part?
How do you delete these parts?
How do you select something inside the the string instead of just on one side? I am not sure but my guess it is like this [:1,2]. For example we'll use the same "Hello World!" string. This would take either "el" or "ll".