Python Mistake - Number of letters in name

后端 未结 3 567
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-29 10:28

Write a program that checks how long a name is. The program should take a name as input from the user.

If the name has 3 or fewer letters, your program should work like

3条回答
  •  离开以前
    2021-01-29 11:18

    You should use len(name) and you don't need int(3) as 3 is already an integer. Your check should look like this:

    name = input('Enter your name: ')
    
    if len(name) >= 3:
       # do stuff
    

    I changed Name to name as this is the standard convention of variable naming in Python.

提交回复
热议问题