Unable to print the exact Float values when I convert LIST to Sequence of Tuples? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Unable to print the exact Float values when I convert LIST to Sequence of Tuples? (/thread-11505.html) |
Unable to print the exact Float values when I convert LIST to Sequence of Tuples? - preethamalluri - Jul-12-2018 Hi, 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 ? 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. Thank you a lot for your time RE: Unable to print the exact Float values when I convert LIST to Sequence of Tuples? - buran - Jul-12-2018 convert = tuple((float(x),) for x in sf) |