Feb-28-2018, 12:27 PM
Why can't I just get two decimal places to the right of the decimal point?
Or are the circumstances with list indexes different:
Or are the circumstances with list indexes different:
#!/usr/bin/env python3 #SamsLists.py myInts = [1,8,4,7,6] for i in myInts: print(i) moneyFloats = [2.1, 6.2, 7.8, 9.1, 5.4] for i in moneyFloats: print("{:,.2f}".format(moneyFloats[i]))
Error:Traceback (most recent call last):
File "I:/Python/Python36-32/SamsPrograms/SamsLists.py", line 10, in <module>
print("{:,.2f}".format(moneyFloats[i], 2))
TypeError: list indices must be integers or slices, not float