dimanche 30 octobre 2016

Python Name error: name not defined, trying to take value input of user to run if function [duplicate]

This question already has an answer here:

im trying to get the input from the user if they put 'yes' it takes that value and runs the if statement function. but i

from sys import argv

script, user_name  = argv # these determine the name of the user and the name of the script

prompt = '> '

print "hi %s, im the %s script." % (user_name, script) # format strings used to call variables when needed

print "i'd like to ask you a few questions"

print "do you like me %s?" % user_name

likes = input('yes') # likes is the varible for the user input

if likes ('yes') :

print "well i dont like you"

This is my error:

 File "ex14.py", line 8, in <module>
 likes = input('yes') # likes is the varible for the user input
 File "<string>", line 1, in <module>
NameError: name 'yes' is not defined
PS C:\Users\lucas\Python folder>

Aucun commentaire:

Enregistrer un commentaire