Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to print the exact Float values when I convert LIST to Sequence of Tuples?
#1
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
Quote
#2
convert = tuple((float(x),) for x in sf)
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Float operations not working after cross-compilation tfgdt 0 57 Jul-09-2018, 05:59 PM
Last Post: tfgdt
  count unique values of a list with a list 3Pinter 2 57 Jul-05-2018, 11:52 AM
Last Post: 3Pinter
  Looping through dictionary and comparing values with elements of a separate list. Mr_Keystrokes 5 137 Jun-22-2018, 03:08 PM
Last Post: wavic
  Unable to install Python 3 PierreSoulier 2 119 Jun-19-2018, 02:35 PM
Last Post: snippsat
  ValueError: could not convert the string to float Grin 3 427 Jun-14-2018, 08:17 PM
Last Post: killerrex
  Get max values based on unique values in another list - python Antonio 8 237 Jun-12-2018, 07:49 PM
Last Post: Mekire
  Convert element of list to integer(Two dimentional array) zorro_phu 3 113 Jun-12-2018, 04:49 AM
Last Post: zorro_phu
  Unable to repopulate a queue in python 3 5u88u 2 142 Jun-08-2018, 01:59 PM
Last Post: 5u88u
  Unable to fetch product url using BeautifulSoup with Python3.6 PrateekG 6 158 Jun-05-2018, 05:49 PM
Last Post: PrateekG
  which sequence is in a sequence Skaperen 3 134 May-28-2018, 01:27 AM
Last Post: Skaperen

Forum Jump:


Users browsing this thread: 1 Guest(s)