【发布时间】:2019-02-01 18:11:51
【问题描述】:
所以我想做的是打印出带有数字和特殊字符的单词列表。现在,我目前正坚持使用范围内生成的数字打印单词。
我已经试过了:
word = input("Enter a word\n>")
firstLetter = word[0]
firstLetter = firstLetter.upper()
length = len(word)
newWord = firstLetter + word[1:length]
print("%s \n".join([str(num).zfill(2) for num in range(0, 10)]) % newWord)
我试过的:
word = input("Enter a word\n>")
firstLetter = word[0]
firstLetter = firstLetter.upper()
length = len(word)
newWord = firstLetter + word[1:length]
print("\n".join([str(num).zfill(2) for num in range(0, 10)]) % newWord)
我期待这样的事情:
Password01
Password02
Password03
Password04
Password05
Password06
Password07
Password08
等等
我的结果:
Python 3.6.1 (default, Dec 2015, 13:05:11)
[GCC 4.8.2] on linux
Enter a word
>pop
Traceback (most recent call last):
File "main.py", line 8, in <module>
print("\n".join([str(num).zfill(2) for num in range(0, 10)]) % newWord)
TypeError: not all arguments converted during string formatting
【问题讨论】:
标签: python string formatting