In Ruby, wenn ich ein Array habe und ich möchte sowohl die Indizes und die Werte in einer Schleife verwenden, verwende ich each_with_index
.Python-Äquivalent von Rubys each_with_index?
a=['a','b','c']
a.each_with_index{|v,i| puts("#{i} : #{v}") }
druckt
0 : a
1 : b
2 : c
Was ist der Pythonic Weg, um die gleiche Sache zu tun?
[enumerate] (https://docs.python.org/3/library/functions.html#enumerate) – grc