python- Trouble Converting User Input to Integer Format

前端 未结 1 1073
天命终不由人
天命终不由人 2021-01-27 12:28
user_input = (\"Enter a number and I will tell you the sum of the multiples of 3 and 5 leading up to it.\")
number = int(user_input)

I am simply trying

1条回答
  •  清歌不尽
    2021-01-27 13:05

    You are not actually prompting for a number. The user_input in your example is the string literal Enter a number and I will tell you the sum of the multiples of 3 and 5 leading up to it., which can not be converted to a number.

    User input can be prompted with input().

    user_input = input("Enter a number and I will tell you the sum of the multiples of 3 and 5 leading up to it.")
    number = int(user_input)
    

    0 讨论(0)
提交回复
热议问题