Hey, hold your horses yo, I hadn't even had a chance to read it yet. :P
All right, the way you'd want to do this is by splitting the input string by spaces, then clean up each string of special characters, capital letters, etc. Then just reverse the list and print it out!
user_input = input("Enter a sentence.\n")
words = user_input.split(' ')
clean_words = []
for word in words:
for n in range(len(word)):
if not word[n:n+1].isalpha():
word = word[:n] + word[n+1:]
if word == "": continue # Just filter out empty strings.
clean_words.append(word.lowercase())
Then print it reversed.
# This is why one tests one's code after not using a language for 6+ months:
#
# for word in clean_words.reversed():
#
# Preserved for posterity.
for word in reversed(clean_words):
print word
Warning: I program to Python 3, it appears you're programming to Python 2 as you're using raw_input. Even though I used input() in my implementation, Python 3's input is the same as Python 2's raw_input.
I very intentionally left this with as little to go on as possible, since what I want you to do is write your own implementation using what you should eventually understand as what's going on in the code. I looked at your code and it appears that you may not even understand how to use for loops to loop over the elements of a sequence. There's a lot of built-in methods in Python that simplify the code you write in it, as well as some nifty shortcuts (though I didn't find one for one of my purposes on this loop). Could you tell me how long you have been programming in Python?
Edited by ZekeDragon, 09 March 2011 - 06:40 PM.