[Python] Is there a way to make 2 different strings function when typed? [closed]

Discussão em 'Python' iniciado por Stack, Junho 3, 2025.

  1. Stack

    Stack Membro Participativo

    I am making my own text app in python and I have this code

    def different_string_func_input(prompt, string1, string2):
    while True:
    custom_input_two = input (prompt)
    if string1 in custom_input_two:
    return custom_input_two
    elif string2 in custom_input_two:
    print("Bye!")
    exit()
    else:
    print("Please enter a valid prompt!")


    I used the while True loop and when I tested it, it showed me this:


    'in ' required string as left operand, not int.
    ​

    It shows up whenever I typed something. Is there a way to fix it?

    Continue reading...

Compartilhe esta Página