variables - Python Mistake - Number of letters in name -
write program checks how long name is. program should take name input user.
if name has 3 or fewer letters, program should work this:
enter name: lin hi lin, have short name.
if name has between 4 , 8 letters (inclusive), program should work this:
enter name: jimmy hi jimmy, nice meet you.
otherwise, if name has more 8 letters, program should work this:
enter name: yaasmeena hi yaasmeena, have long name.
here's attempt returns "hi xxxxxxx, have short name" regardless of length.
name = input('enter name: ') if name.count('name') >= int(3): print ('hi', 'name', ',', 'nice meet you.') elif name.count('name') <= int(3): print ('hi', 'name', ',', 'you have short name.') elif name.count('name') > int(8): print ('hi', 'name', ',', 'you have long name.')
you should use len(name)
, don't need int(3)
3
integer. check should this:
name = input('enter name: ') if len(name) >= 3: # stuff
i changed name
name
standard convention of variable naming in python.
Comments
Post a Comment