Unable to compare input lines in Python 3.2

Python has a very strange problem. These two did not seem to help:

Checking user input strings in Python and a quick way to compare strings in python

I wrote the following small test.py program:

import sys
while True:
    print("\n")
    print("Type exit to exit: ")

    inputvar = str(input())
    print("Input: "+inputvar)

    if inputvar == 'exit':
        print("Exiting!")
        sys.exit("\n\nProgram quit.")
    else:
        print("Still here")

The current version does not seem to come with exit, 'exit'or "exit". Using input()instead str(input())does not seem to matter, and using isor ininstead ==does not matter either.

I am using Python 3.2 on Windows 7.

+4
source share
2 answers

Python 3.2.0 , \r input(): . ( 3.2.1). :

inputvar = input().rstrip()
+7

input()

str (input())

inputvar = input().strip()
-3

All Articles