Python 我正在尝试一个密码生成器程序,我';我有一个错误显示:TypeError:只能将列表(而不是“str”)连接到列表

Python 我正在尝试一个密码生成器程序,我';我有一个错误显示:TypeError:只能将列表(而不是“str”)连接到列表,python,Python,我正在创建一个密码生成器程序,在执行时显示以下错误:TypeError:只能将列表(而不是“str”)连接到列表 我是python新手,需要这方面的帮助 import random import string adjectives = ['fast', 'slow', 'fat', 'red', 'smelly', 'wet', 'green', 'orange', 'blue', 'white', 'brave', 'purple'] nouns = ['apple', 'dinosaur'

我正在创建一个密码生成器程序,在执行时显示以下错误:TypeError:只能将列表(而不是“str”)连接到列表 我是python新手,需要这方面的帮助

import random
import string
adjectives = ['fast', 'slow', 'fat', 'red', 'smelly', 'wet', 'green', 
'orange', 'blue', 'white', 'brave', 'purple']
nouns = ['apple', 'dinosaur', 'ball', 'toaster', 'dragon', 'panda', 
'team', 'hammer']
print 'Welcome to password picker'
adjective = random.choice(adjectives)
noun = random.choice(nouns)
number = random.randrange(0,100)
special_char = random.choice(string.punctuation)
password = adjectives + noun + str(number) + special_char
print 'Your New Password is : %s' % password  

它应该打印随机生成的密码,如OrangeDinosaur32!etc

您正在将一个字符串连接到一个列表,如下所示:

password = adjectives + noun + str(number) + special_char
形容词是一个列表,而str(number)是一个字符串,特殊字符也是

我假设你想要这个:

password = adjective + noun + str(number) + special_char
差别很小,但应该有效

欢迎使用密码选择器
你的新密码是:redpanda6=

你的意思是
密码=…