x=str(raw_input("What do you want to convert from? Just enter 'gal', 'lb', or 'mi': ")) y=str(raw_input("What do you want to convert to? Just enter 'l', 'kg', or 'km': ")) if (x=="gal" and y=="l")or(x=="lb" and y=="kg")or(x=="mi" and y =="km"): if x == "gal": x=float(input("So you want to convert from gallons? How many gallons do you want to convert from?: ")) y=x*3.78541 print "Done! There are "+str(y)+"liters in "+str(x)+"gallons!" else if x == "lb": x=float(input("So you want to convert from pounds? How many pounds do you want to convert from?: ")) y=x*0.45359 print "Done! There are "+str(y)+"kilograms in "+str(x)+" pounds!" else: x=float(input("So you want to convert from miles? How many miles do you want to convert from?: ")) y=x*1.60934 print "Done! There are "+str(y)+"miles in "+str(x)+" kilometers!" else: print("Incompatible conversion.")
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question