Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок0
How does the compiler know what dot is and if you replace dit with other words it still works why?
words = ["hello", "world", "spam", "eggs"] for dot in words: print(dot + "!")
2 ответов
+ 1
Dot is a variable which refers to the current iteration of the list. So, you'd access that the same way you'd access everything else.
@donkeyhot
Yeah. I'm just used to calling lists/arrays tables. As far as iteration in a for loop goes, I was referring to the value within a certain index in a list. Corrected myself in OP.
+ 1
dot is just a name of your variable. You can name it whatever you like, even gigantic_alien_pizza. In your code, it iterates through words list.
@Ben, it's called a list, not a table. And iterating a for loop has nothing to do with indexes.