Show-Me-the-Code / python

Show Me the Code Python version.
https://github.com/Show-Me-the-Code/show-me-the-code
MIT License
3.91k stars 2.74k forks source link

Python #404

Open Ducky0808 opened 2 years ago

Ducky0808 commented 2 years ago

image

gitoleary commented 2 years ago

It may seem you are multiplying two integers but that is not the case. The arguments entered into the input function must be a string to prompt the user, ID = input("Enter a number: ") What is happening in your code is that you are printing "17362", then waiting for a key press "ENTER" and then multiplying that key press or empty string by a,b,c,d. This is the cause of the ValueError.

sayampradhan commented 1 year ago

It is because you are giving a string in the input where which accepts only and only integer. Just change the input you are giving and that's it. You are good to go.

Correct Code

while True:
    ID = int(input("Write a number: "))
    a = 19
    b = 43106
    c = 54
    d = 986510

    print(ID * a + b * c + d)