- 1
Let's say I don't want the user input's output, if it were a whole number, to be x.0, how would I do that?
Seems a bit confusing I know. Let me show you: user_input=float(input("Enter a number")) user_input=12 a=user_input + 12 print(a) If I'm not mistaken the output would be 24.0, is there a way to get rid of the .0 part? I don't want to get rid of it if it's not a whole number, just if it is a whole number.
5 Respuestas
0
i C programing u can use %d.0 yo undo the .0
i think in python u can use the same think to undo the .0
0
Why make it a float in the first place?
0
Because I need it to be defined as a number and, if necessary, have a decimal.
I'm trying to make a calculator and I've succeeded but I think the .0 at the end is a bit ugly if unnecessary. It's not that big of a deal, I was just wondering.
0
try this?
user_input=input("enter num")
//input 12
total= input +12
if total = float(total)
print (float(total))
else
print(total)
0
==*