我需要用 python 程序制作一个刽子手程序,但我不知道如何继续。在程序中,我有 6 次机会(也称为“生命线”)来猜测单词中的字母。每一次错误的猜测都会缩短“生命线”。当你猜对了单词或者你用完了你所有的“生命线”时,游戏就会结束。这是示例输出:
['_', '_', '_', '_']
***Life Line***
-+-+-+-+-+-+
$|$|$|$|$|$|
-+-+-+-+-+-+
Enter your guess: a
['_', '_', '_', '_']
***Life Line***
-+-+-+-+-+
$|$|$|$|$|
-+-+-+-+-+
Incorrect Guess: ['a']
...................................
Enter your guess: b
['b', '_', '_', '_']
***Life Line***
-+-+-+-+-+
$|$|$|$|$|
-+-+-+-+-+
Incorrect Guess: ['a']
...................................
Enter your guess: l
['b', 'l', '_', '_']
***Life Line***
-+-+-+-+-+
$|$|$|$|$|
-+-+-+-+-+
Incorrect Guess: ['a']
...................................
Enter your guess: o
['b', 'l', '_', '_']
***Life Line***
-+-+-+-+
$|$|$|$|
-+-+-+-+
Incorrect Guess: ['a', 'o']
...................................
Enter your guess: u
['b', 'l', 'u', '_']
***Life Line***
-+-+-+-+
$|$|$|$|
-+-+-+-+
Incorrect Guess: ['a', 'o']
...................................
Enter your guess: e
['b', 'l', 'u', 'e']
***Life Line***
-+-+-+-+
$|$|$|$|
-+-+-+-+
Incorrect Guess: ['a', 'o']
...................................
You Got it Right! Well Done!
我已经输入了前几个代码但卡住了。
import random
wordList = ["Mary","Tian Pei","Pong"]
randname = random.choice ( wordList)
print randname
resultList = [ ]
for i in range(len(randname)):
resultList.append("_")
print resultList