So I tried using this block of code but what it does is it puts the items from resources index 0 and 1 into both variables on the first iteration. I want a way to where resources will map to alph and range will map to i. Is this possible in python?
resources = ["a", "b", "c"]
for alph, i in resources, range(len(resources)):
print(alph)
if i == 2:
print(2)
I’m basically looking for something similar to golang’s range where you would type
resources := ["a", "b", "c"]
for incrementer, alph := range resources {
fmt.Print(alph)
if i == 2 {
fmt.Print(2)
}
}
>Solution :
This should work
resources = ["a", "b", "c"]
for key, value in enumerate(resources):
if value == "a":
print(str(key) + "-" + value)