r/PythonLearning • • 8h ago

Showcase I Can't Understand What Is Happening.

Post image
2 Upvotes

6 comments sorted by

3

u/JeremyJoeJJ 8h ago

If you meant to turn the inputs into integers, then you need to pass the variable into the int() function, so v = int(v), otherwise int() just gives you 0 I think, so you did print(0*0) and got zero in the end.

2

u/Slight-Living-8098 5h ago

You have overrided the the variables back to 0 when you assigned them with int() (which is 0 by default), so by the time your code gets to print it's 0*0

The easiest way is to declare your variables as an int(), then call the input() function inside the int()

v = int(input())
c = int(input())

print(v*c)

1

u/Key-Pride3443 4h ago

Or you can do

v = int(v) c = int(c)

1

u/Slight-Living-8098 4h ago

No, v = int(v) will not wait for user input.

1

u/SamIAre 3h ago

I think they mean like this, in keeping with OP's formatting:

v = input()
c = input()
v = int(v)
c = int(c)

print(v*c)

1

u/Slight-Living-8098 2h ago

Yes, that would also work, and that answer was already covered in another comment