Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use a list of floats
#5
Stripping out the GUI still gives the error:
Error:
Traceback (most recent call last):   File "C:\Users\kb\Desktop\Python\test2.py", line 36, in <module>     for fred in total: TypeError: 'float' object is not iterable
import os
import math


global file_path
global total

file_path = raw_input("location: ")
filepaths = []
    
#gets list of avi    
for basename in os.listdir(file_path): 
    filename = os.path.join(file_path, basename)
    if not filename.endswith(('.mov', '.AVI', '.avi')): continue
    if os.path.isfile(filename):
        filepaths.append(filename)

# Re-populate list with size, convert to GB
for i in xrange(len(filepaths)):
    filepaths[i] = (os.path.getsize(filepaths[i]))
    nums = filepaths[i]
    i = int(math.floor(math.log(nums, 1024)))
    p = math.pow(1024, i)
    s = round(nums/p, 2)
    total = s
    print total
    
count = 0
for fred in total:
    fred= (s * .20)
    if fred > 4.5:
        count = count +1
print count
Reply


Messages In This Thread
How to use a list of floats - by kristrek - Jan-23-2017, 09:28 PM
RE: How to use a list of floats - by micseydel - Jan-23-2017, 09:39 PM
RE: How to use a list of floats - by kristrek - Jan-24-2017, 03:26 PM
RE: How to use a list of floats - by micseydel - Jan-24-2017, 06:41 PM
RE: How to use a list of floats - by kristrek - Jan-25-2017, 05:02 PM
RE: How to use a list of floats - by wavic - Jan-25-2017, 05:13 PM
RE: How to use a list of floats - by snippsat - Jan-25-2017, 05:49 PM
RE: How to use a list of floats - by kristrek - Jan-25-2017, 06:44 PM
RE: How to use a list of floats - by micseydel - Jan-25-2017, 06:57 PM
RE: How to use a list of floats - by wavic - Jan-25-2017, 07:09 PM
RE: How to use a list of floats - by kristrek - Jan-25-2017, 08:37 PM
RE: How to use a list of floats - by wavic - Jan-25-2017, 08:44 PM
RE: How to use a list of floats - by kristrek - Jan-25-2017, 09:30 PM
RE: How to use a list of floats - by wavic - Jan-26-2017, 01:04 AM
RE: How to use a list of floats - by snippsat - Jan-26-2017, 05:33 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  When is it safe to compare (==) two floats? Radical 4 794 Nov-12-2023, 11:53 AM
Last Post: PyDan
  floats 2 decimals rwahdan 3 1,668 Dec-19-2021, 10:30 PM
Last Post: snippsat
  rounding and floats Than999 2 3,152 Oct-26-2020, 09:36 PM
Last Post: deanhystad
  int, floats, eval menator01 2 2,476 Jun-26-2020, 09:03 PM
Last Post: menator01
  Stuck comparing two floats Tizzle 7 3,075 Jun-26-2020, 08:23 AM
Last Post: Tizzle
  rounding floats to a number of bits Skaperen 2 2,340 Sep-13-2019, 04:37 AM
Last Post: Skaperen
  comparing fractional parts of floats Skaperen 4 3,402 Mar-19-2019, 03:19 AM
Last Post: casevh
  Integer vs Floats Tazbo 2 2,906 Jan-09-2019, 12:06 PM
Last Post: Gribouillis
  Formatting floats Irhcsa 6 4,225 Oct-04-2018, 04:23 PM
Last Post: volcano63
  How do you sort a table by one column?? (of floats) sortedfunctionfails 3 12,366 Jan-11-2018, 09:04 AM
Last Post: sortedfunctionfails

Forum Jump:

User Panel Messages

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