Answers for "enumerator python"

24

enumerate python

for index,subj in enumerate(subjects):
    print(index,subj) ## enumerate will fetch the index
    
0 Statistics
1 Artificial intelligence
2 Biology
3 Commerce
4 Science
5 Maths
Posted by: Guest on April-25-2020
1

enumeration python

from enum import Enum

class Color(Enum):
    RED = 1
    GREEN = 2
    BLUE = 3

print(Color.RED)

class Shake(Enum):
	VANILLA = 7
    CHOCOLATE = 4
    COOKIES = 9
    MINT = 3
Posted by: Guest on January-26-2021

Python Answers by Framework

Browse Popular Code Answers by Language