【发布时间】:2019-10-02 17:54:54
【问题描述】:
我正在尝试用单引号打印最终输出,但不知道该怎么做。对python有点陌生,所以任何让我走上正轨的指导都会有所帮助。
我尝试在打印函数中将引号与变量连接起来,但出现“无效语法”错误
sample = []
while True:
print ('Enter items into this list or blank + enter to stop')
name=input()
if name == '':
break
sample = sample + [name]
print(sample)
sample.insert(len(sample)-1, 'and')
print(sample)
print('Here is the final output:')
print(*sample, sep = ", ")
最终输出显示类似这样的内容: A、B、C、D
但是,所需的输出是: 'A,B,C,和,D'
【问题讨论】:
标签: python-3.x variables quotes