[Python] How to make this loop repeat until right value has been added, Python

Discussão em 'Python' iniciado por Stack, Julho 7, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to get the below code to repeat until one of the correct string values is entered.

    while True:
    if value in ['man united', 'man city', 'liverpool', 'chelsea']:
    print(tabulate(data[value]))
    break
    if value not in ['man united', 'man city', 'liverpool', 'chelsea']:
    print("You entered a wrong option, Please enter a correct option")
    print(f"1: {options}")


    I've tried a couple different ways but can't achieve exactly what I'm looking for. This code is within a python function.

    Any help is greatly appreciated. New to Python

    Continue reading...

Compartilhe esta Página