Answers for "python how to find if loop at last element in list"

3

check if is the last element in list python

if x == my_list[-1]:
    # do what you want
Posted by: Guest on August-28-2020
0

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
Posted by: Guest on September-05-2021

Code answers related to "python how to find if loop at last element in list"

Python Answers by Framework

Browse Popular Code Answers by Language