Answers for "for loop enum python"

1

for loop with enumerate python

presidents = ["Washington", "Adams", "Jefferson"]
for num, name in enumerate(presidents, start=0):
    print("President {}: {}".format(num, name))
Posted by: Guest on June-25-2020
0

how to loop through a python enum

from enum import Enum
class Country(Enum):
    Afghanistan = 93
    Albania = 355
    Algeria = 213
    Andorra = 376
    Angola = 244
    Antarctica = 672
for data in Country:
    print('{:15} = {}'.format(data.name, data.value))
Posted by: Guest on May-22-2021

Python Answers by Framework

Browse Popular Code Answers by Language