Skip to content Skip to sidebar Skip to footer

Revised To Earlier Question: Program Laps To Miles

import re user_miles = input() def miles_to_laps(user_miles): miles = float(user_miles) * 4 print('%0.2f'% miles) return miles_to_laps(user_miles) def parse_function_tex

Solution 1:

This line of code accepts an input, but always returns a string, so if you type a 20 as a response to this input, it is stored in memory as a '20' (a string OR str type)

user_miles = input()

Your function is intended to perform math and thus expects numbers (i.e. integer type (int) OR a float type (float).

The easiest way to fix this is to immediately convert the string to an integer, using the int() function to wrap the input() function.

user_miles = int(input())

Post a Comment for "Revised To Earlier Question: Program Laps To Miles"