I'm new to python, and trying to figure out how to have it do some division in the end of my program.
Eariler in the program, it asks the user for a number that can be divided by 20 as seen here:
if int(Integer) % 20 == 0:
True
I then want later to have it take that number and divide it by 20. I figured I could do it using the following command:
print(int(Integer // 20)
However, I then get the following error message: TypeError: unsupported operand type(s) for //: 'str' and 'int'
Is there another command I can use to have it do that division at the end and give me the output?
Answer
Probably int() the integer first to ensure that it is an integer, not a string or any other value type.
You can check the integer value by using print(type(Integer))
and make sure that it prints: <class 'int'>
in the console.
Also, //
is floor division, /
is regular division and %
is to find the remainder after division.
Make sure you are using the right division.
Happy coding!