Python Forum

Full Version: Unable to print the exact Float values when I convert LIST to Sequence of Tuples?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, Smile I have the following LIST in python, I am trying to convert it from this format to SEQUENCE OF TUPLES. I am able to convert it into a tuple but unable to get the desired output. Can someone please go through the code I have mentioned below ? Smile

List_to_be_converted = sf
sf = ['4.1', '4.2', '4.3', '4.4', '4.5', '4.6', '4.7'] **sad** 
#code to convert #
convert = tuple((float(x[0]), ) for x in sf)
#output after running the code
convert = ((4.0,), (4.0,), (4.0,), (4.0,), (4.0,), (4.0,), (4.0,))

Expected output = ((4.1,), (4.2,), (4.3,), (4.4,), (4.5,), (4.6,), (4.7,))
I am unable to see the decimal values of the output. Wall
Thank you a lot for your time
convert = tuple((float(x),) for x in sf)