就像在电影和游戏中一样,一个地方的位置出现在屏幕上,好像它是在现场打字一样.我想做一个关于在python中逃离迷宫的游戏.在游戏开始时,它给出了游戏的背景信息:
line_1 = "You have woken up in a mysterious maze"
line_2 = "The building has 5 levels"
line_3 = "Scans show that the floors increase in size as you go down"
Run Code Online (Sandbox Code Playgroud)
在变量下,我试着为每一行做一个for循环,类似于:
from time import sleep
for x in line_1:
print (x)
sleep(0.1)
Run Code Online (Sandbox Code Playgroud)
唯一的问题是它每行打印一个字母.它的时机还可以,但我怎么能让它在一条线上?
如果我想通过其值而不是索引删除项目,我该怎么办?
animals = ['tiger', 'snake', 'penguin','giraffe']
Run Code Online (Sandbox Code Playgroud)
说我想删除'penguin'而不打字del animals[2]我怎么去呢?
我试过打字,del animals['penguin']但它不起作用......
如何在Python中以列表格式最有效地生成52张卡片,以便列表如下所示:
['1 of Spades', '1 of Hearts', '1 of Clubs', '1 of Diamonds', '2 of Spades', '2 of Hearts' 等等