Apr-11-2022, 01:24 PM
You said that you want this:
Output:>>> foo(3.25)
'3.25'
>>> foo(4.0)
'4'
>>>
and I gave you this:Output:>>> def foo (floating_point_number) :
... integer = int (floating_point_number)
... if integer == floating_point_number :
... return integer
... return floating_point_number
...
>>> foo (3.25)
3.25
>>> foo (4.0)
4
>>>
The only difference I see is the quotation marks. Is that what your looking for? If not, can you explain exactly what the difference is?