Help with type conversion | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help with type conversion

I tried running this example but it is giving me error. could somebody please please explain to me what's wrong with it? print(float(input("Enter a number: ")) + float(input("Enter another number: ")))

24th Dec 2016, 5:01 AM
Carlos Rodriguez
Carlos Rodriguez - avatar
2 Answers
+ 2
Wrap the addition operation of your floats with a format() so that it is ready for the print operation. print(format(float(input("Enter a number: "))+float(input("Enter another number: ")))) EDIT: Ran on Windows(v3) and Linux (v2) consoles and both versions worked as written. Where were you trying to run this?
24th Dec 2016, 6:35 PM
Kevin Gilkey-Graham
Kevin Gilkey-Graham - avatar
0
I get EOFError. I think it might be the compiler of the app, I haven't tried it in a pc.
25th Dec 2016, 2:35 AM
Carlos Rodriguez
Carlos Rodriguez - avatar