【问题标题】:Assigning variables to a set将变量分配给集合
【发布时间】: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


猜你喜欢
  • 2018-07-06
  • 2012-09-06
  • 2014-05-11
  • 2020-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-17
  • 1970-01-01
相关资源
最近更新 更多