Skip to content

07-word-completion-basic-edition #10

@GeekDGirl

Description

@GeekDGirl

I have been working on this addition to the RPS game. I have installed prompt-toolkit 3.0.5. As I have been coding along with you, I have received the following error:
File "/PycharmProjects/RPS/RPS-v8.py", line 157
word_comp: object = word_completer(roll_names)
^
SyntaxError: invalid syntax

I can't figure out what is causing the error as I have attempted to follow your code...there were some differences that came up when I entered the WordCompleter...the autofill had me use word_completer for example. Below is the section of code that relates:

def get_roll(player_name, roll_names):
print(f"Available rolls: {', '.join(roll_names)}"
# for index, r in enumerate(roll_names, start=1):
# print(f"{index}. {r}")

word_comp = word_completer(roll_names)
roll = prompt(f"{player_name}, what is your roll: ", completer=word_comp)

text = input(f"{player_name}, what is your roll?")
selected_index = int(text) - 1

if not roll or roll not in roll_names:
    print(f"Sorry {player_name}, {roll} is not valid!")
    return None

return roll

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions