[Python] Why does my Python check for "among us always imposter" string return False?

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

  1. Stack

    Stack Membro Participativo

    I'm learning Python and working on a small personal project: a script that checks the title of an Among Us game lobby to see if it's running a special game mode.

    I was inspired by some of the creative custom game rules discussed by the community. For context, the kind of logic and game modes I'm trying to detect are similar to the ones described in this community breakdown here:

    https://modhello.com/among-us

    My goal is simple: write a function that returns True if the lobby title contains the phrase "always imposter". However, my function always returns False and I can't figure out what I'm doing wrong.

    Here is my minimal reproducible code:

    def is_always_imposter_lobby(lobby_title):
    """
    Checks if the lobby title indicates it's an 'always imposter' game.
    Expected to return True for a title like "Room 5 - always imposter mode!".
    """
    # This is the line I think is wrong
    if lobby_title == "among us always imposter":
    return True
    else:
    return False

    # --- My Test Case ---
    # This is a sample title my script would get
    test_lobby_title = "Joe's Fun Game (among us always imposter rule)"

    # Running the function
    result = is_always_imposter_lobby(test_lobby_title)

    # I expect this to print True, but it prints False
    print(f"Is this an always imposter lobby? {result}")



    I've been staring at this and I feel like I'm missing something very basic about string comparison in Python.

    My test_lobby_title clearly contains the text "among us always imposter", so why does the if check fail? What is the correct way to check if a string contains another substring, rather than being an exact match?

    Continue reading...

Compartilhe esta Página