如何在不转到下一个索引的情况下继续for循环python

如何在不转到下一个索引的情况下继续for循环python,python,for-loop,keyword,Python,For Loop,Keyword,是否有任何方法可以在不转到下一个索引的情况下继续for循环 例如: for player in range(players): name = input("what is your name? ").lower() if name == "john cena": print("Hey! That's not your real name!") [some keyword or function that allows the magic to ha

是否有任何方法可以在不转到下一个索引的情况下继续for循环

例如:

for player in range(players):
    name = input("what is your name? ").lower()
    if name == "john cena":
        print("Hey! That's not your real name!")
        [some keyword or function that allows the magic to happen]
    elif name == "donald trump":
        print("Hi Mr. President!")
        [the same keyword or function that allows the magic to happen]

    player_names.append(name)
外壳:

============ RESTART =========

what is your name? luke
what is your name? john cena
Hey! That's not your real name!
what is your name? donald trump
Hi Mr. President!
what is your name? mickey mouse
what is your name? nobody
>>> player_names
["luke", "mickey mouse", "nobody"]

for
循环允许您在每个元素上迭代一次,而不必担心如何实际移动到下一个索引

for each player:
   # do something
如果需要对何时或是否要移动到下一个索引进行更多控制,可以使用
while
循环

while (some_condition_is_true):
   # do something

不!不过,您可以在那里放置
while
循环。。。那太令人失望了。。。无论如何谢谢你的帮助谢谢!我正在做一个非常难的游戏,有很多令人困惑的代码。必须找到一种方法用while循环替换for循环。