Python Forum
ValueError - Formatting issue when values enter thousands
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ValueError - Formatting issue when values enter thousands
#4
Your string has thousands separator, so you need to strop that in order to convert to float:
total_cost += float(cell_value[1:].replace(',', ''))
That said, probably your code can be simplified
phillyfa likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: ValueError - Formatting issue when values enter thousands - by buran - Apr-20-2023, 11:17 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ValueError: Length mismatch: Expected axis has 8 elements, new values have 1 elements ilknurg 1 5,381 May-17-2022, 11:38 AM
Last Post: Larz60+
  formatting float like int for whole values Skaperen 8 1,923 Apr-11-2022, 01:56 PM
Last Post: deanhystad
  ValueError: not enough values to unpack (expected 4, got 1) vlearner 2 6,464 Jan-28-2022, 06:36 PM
Last Post: deanhystad
  [SOLVED] [geopy] "ValueError: too many values to unpack (expected 2)" Winfried 2 2,973 Mar-30-2021, 07:01 PM
Last Post: Winfried
  ValueError: not enough values to unpack (expected 2, got 1) Wolfpack2605 1 12,741 Jan-27-2018, 11:52 AM
Last Post: buran
  Dictionary Comprehension - ValueError: too many values to unpack (expected 2) samRddhi 2 8,583 Dec-22-2017, 09:25 AM
Last Post: samRddhi
  valueError too many values to unpack iFunKtion 7 90,619 Apr-29-2017, 05:16 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020