March 13th, 2004, 02:29 AM
Join Date: Mar 2004
Time spent in forums: < 1 sec
Reputation Power: 0
Re: comparing user input against a string (newbie)
I believe the problem is that sys.stdin.readline() will read in the whole line, including the carriage return ("\n") at the end. According to the Python docs:
| readline( [size]) |
Read one entire line from the file. A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line).
If you wish to remove the newline character try rstrip(). Here's your code modified to (hopefully) work:
print "Pls input the nominated text: "
ui = sys.stdin.readline()
ui = ui.rstrip("\n")