简体   繁体   中英

Asking for input in Python 3.4

entry = input("Enter a word:")

if entry == whatever:
    print("print this")

I keep getting error whatever is not defined. Why? I want to define it through input

whatever is a string which you are comparing your input with, so you need to put it in quotes. As in

if entry == 'whatever':

Now a small demo after the necessary edit will output

Enter a word:whatever
print this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM