0
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 to obtain input from the user and do certain tests on it. For example, if number > 0:. In order to do this, I assumed that user input data is automatically stored as a string and to remedy this, one would do what is provided in the code box. However, when doing this operation, I get ValueError: invalid literal for int() with base 10: 'Enter a number and I will tell you the sum of the multiples of 3 and 5 leading up to it.' Clearly I am doing this wrong. Can someone shed light on how to do this correctly?

-Thank you in advance :)

1 Answer 1

3

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)
Sign up to request clarification or add additional context in comments.

1 Comment

Hi @AlpineXJedi if this has solved your question please consider accepting it by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.