【发布时间】:2022-06-14 21:56:33
【问题描述】:
我正在尝试使用一组变量创建一个随机问题生成器,例如:
set1 = {"a","b","c","d"}
a = "What is the name of the city where you were born?"
b = "What is the name of your first pet? "
c = "What is the make of your first car? "
d = "What is your mother's maiden name? "
print(set1)
这是不可能的,因为元素不能改变吗?
如果是这样并且我将集合更改为列表,我可以随机打印列表的元素吗?
【问题讨论】:
-
你没有一组变量,你有一组字符串。如果您想要一个包含这四个问题的字符串的集合,请在定义它们之后写
set1 = {a, b, c, d}。
标签: python