我有什么
import random
listofLetters =['k', 'i', 'n', 'g']
x = random.choice(listofLetters)
print x
listDash = []
print "Welcome to Gues the Letter Game!"
print " "
print "=" * 5 + "Start of Game" + "=" * 5
print ['_', '_', '_', '_', '_']
print " "
maxLife = 4
print "*" * 3 + "Life Line" + "*" * 3
print "-+" * maxLife
print "$|" * maxLife
print "-+" * maxLife
print " "
guess = raw_input("Enter your guess: ")
howmanyletter = len(guess)
if guess == x:
print "*" * 3 + "Life Line" + "*" * 3
print "-+" * maxLife
print "$|" * maxLife
print "-+" * maxLife
else:
print "Incorrect Guess []
我希望将 []
替换为猜测
例如[k]
最佳答案
以下是有关 Python 的一些信息 string.format method .
x=raw_input("guess? ")
print "Incorrect guess [{}].".format(x)
关于python - 将 [ ] 替换为 raw_input,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17961147/