What's problem with this code ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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))

27th Oct 2016, 10:21 AM
Ali
4 Answers
+ 2
def inchesToCm(inches): return inches*2.5 #Example of use print(inchesToCm(30))
27th Oct 2016, 10:24 AM
Zen
Zen - avatar
+ 1
X = Input("enter a number: ") Print(x *= 2.5)
28th Oct 2016, 8:39 AM
Linus Izthebest
Linus Izthebest - avatar
+ 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
28th Oct 2016, 5:48 PM
seamiki
seamiki - avatar
0
user_input= int(input()) if user_input: print (user_input*2.5'cm')
12th Nov 2016, 2:48 PM
Iniobong Uyah
Iniobong Uyah - avatar