python - How to put a blank space in a list? -
python - How to put a blank space in a list? -
example, want create list:
a = [1, 2, 3, , 5]
how set in blank space in between 3
, 5
? want create game of hangman it, , blank space filled in player. list contain hangman question player need solve.
you can't leave "empty space" in list; each index has contain something. in general, "empty" index indicated sentinel value, none
.
for game hangman, have own empty space character, e.g. underscore "_"
:
word = ["h", "e", "_", "_", "o"]
this allows print
word
, showing user blanks are:
>>> print " ".join(word) h e _ _ o
python
Comments
Post a Comment