Nothing to do with Python. To brush the PAT again, the output encountered a problem like this:
Topic 1002 topic requires the output of the sum of each of the numbers of N in a row, there are 1 spaces between the phonetic numerals, but there is no space after the last phonetic number in a row,
However, the print statement in Python is followed by a newline character, with a comma followed by a smart line that turns the newline into a space
Attach 1002 Code:
#!/usr/bin/python
ImportSys
N = int(Sys.ARGV[1])
Count=0
whileN!=0:
Count=Count+N%10
N =N/10
Ans=[ ]
whileCount!=0:
Ans.insert(0,Count%10)
Count=Count/10
Dic= {0:"Ling", 1:"Yi", 2:"ER",3:"San",4:"Si",5:"WU",6:"Liu",7:"Qi",8:"BA",9:"JIU"}
forIIn range(Len(Ans)):
PrintDic[Ans[I]],
A comma is primarily a tuple conversion in a type conversion, and a comma is required to convert to a tuple type only when there is only one element in the tuple:
such as: b= (one,) #b为一个元组, and the element has only a single
The magical character of commas in Python