Python未从lis打印

2024-04-24 19:03:04 发布

您现在位置:Python中文网/ 问答频道 /正文

from random import randint


person = ["My friend", "My sister", "Joe mama", "Barack Obama"]
speech = ["said", "shouted", "whispered"]
personSecond = ["he", "she"]
expression = ["likes", "hates", "always thinks about"]
ing = ["playing computer games", "dominating the world"]

w = randint(0,3)
x = randint(0,2)
y = randint(0,2)
z = randint(0,3)

print(person[w], speech[x], end = " ")

if w == '0' or w == '3':
    print(personSecond[0], end = " ")
elif w == '1' or w == '2':
    print(personSecond[1], end = " ")

print(expression[y], ing[z])

我只得到人、语言、表情和声音的输出。Python不打印personSecond列表中的字符串

我做错了什么


Tags: orfromimportfriendmyrandomsisterspeech