Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python "for in" loop to print the last item in the list

>>> total = 0
>>> for n in [5.99, 12.99, 20.99, 129.99]: 
        total += n
        print('Total is now', total)

Total is now 5.99
Total is now 18.98
Total is now 39.97
Total is now 169.96		
>>> total  
169.96 
Source by sites.pitt.edu #
 
PREVIOUS NEXT
Tagged: #Python #loop #print #item #list
ADD COMMENT
Topic
Name
7+5 =