我的代码是:
print("you slowly open your eyes and look around.\n")
print
print("The room you are in has a chest of drawers in the corner, a nightstand, and a loose floorboard.\n")
print
place = input ('What do you examine first: ' )
print("you inspect the place. Underneath you find a small stick.")
不幸的是,当我对其进行测试时,最后的打印顺序是:
您检查该地点。在下方找到一个小棍子
与其说:
您检查地板/橱柜/床头柜。在下面找到一个小棍子。
我在做什么错了?
答案 0 :(得分:0)
最后一行中的“位置”只是一个字符串,而不是您之前获得的变量,您需要将变量注入整个字符串。
类似如下:
place = input ('What do you examine first: ' )
print("you inspect the %s. Underneath you find a small stick." % place)
更多方法可以参考this。
答案 1 :(得分:0)
使用它,它将起作用
print(f"you inspect the {place}. Underneath you find a small stick.")