开发者

How to add a space for user?

开发者 https://www.devze.com 2023-03-06 19:15 出处:网络
If i had a word that had space, like abc def for user to guess, and i want to input the space, so user don\'t have to guess the space.

If i had a word that had space, like abc def for user to guess, and i want to input the space, so user don't have to guess the space.

Beacuse i had a code like this:

if len(letter)==1 and letter.isalpha():
            if letters_tried.find(letter) != -1:
开发者_开发知识库

Befor user gusee is:

_ _ _ _ _ _ _

If guess the letter:

abc_def

is missing the space.

I want user only input alpha and i'll input the space for user. Is there away to do it?


Maybe you are looking for next:

inputs = ["abc def", ...]
inputs_map = zip(inputs, [i.replace(' ', '') for i in inputs])

user_input = get_user_input()

user_input = inputs_map.get(user_input, user_input)
0

精彩评论

暂无评论...
验证码 换一张
取 消