+ 2
What's problem with this code ?
I want to write a program which receives a number + inch and gives back the number * 2.5 (cm) P.s: I know it might have lots of problems, I'm a new learner:( if user_input(num+(inch)): output(num*2.5) output=n print(n+(cm))
4 Respostas
+ 2
def inchesToCm(inches):
return inches*2.5
#Example of use
print(inchesToCm(30))
+ 1
X = Input("enter a number: ")
Print(x *= 2.5)
+ 1
try this. Works as you described:
user_input= input("enter a number followed by ' inch' or ' inches''': ")
input_validation = user_input.find( " inch" )
if (input_validation > 0 ):
inches_value = int(user_input[ 0 : input_validation ])
print (str(inches_value * 2.5) + " cm")
if the string " inch" is found in the user input, the program extracts the value string, converts it to an integer value, does the conversion operation and prints out the converted centimeters
0
user_input= int(input())
if user_input:
print (user_input*2.5'cm')