当进入下面的代码我得到完全的输出我想:打印列表标记
entrants = ['a','b','c','d']
# print my list with square brackets and quotation marks
print (entrants)
#print my list without brackets or quotes
#but all on the same line, separated by commas
print(*entrants, sep=", ")
#print my list without brackets or quotes, each element on a different line
#* is known as an 'identifier'
print(*entrants, sep="\n")
然而,当我输入以下代码:
values = input("Input some comma separated numbers: ")
List = values.split(",")
Tuple = tuple(List)
print('List : ', List )
print('Tuple : ', Tuple)
print('List : ', sep=",", *List )
print('Tuple : ', sep=",", *Tuple)
我得到一个空间和逗号前的最后两行输出的第一个值如下:
List : ['1', '2', '3']
Tuple : ('1', '2', '3')
List : ,1,2,3
Tuple : ,1,2,3
我该怎么做错了吗?
你不认为它会算初始的字符串? –