The code that I'm struggling with.
CodePudding user response:
input()
returns a string. So in order to calculate distanceTraveled you have to cast it to int or float. If you can input a value like 5.5 seconds, you'll have to use float.
distanceTraveled = float(num1) * num2
CodePudding user response:
The input()
function treats any user input as a string. And so when you multiply by an integer like 1480, it prints the user input 1480 times.
You should type cast the input - type casting is changing one datatype into another datatype providing that the operation is possible with the given data.
this is done like this:
num1 = int(input("Enter number"))