Python 3.x 努布可怕地陷入了一个很可能很简单的问题

Python 3.x 努布可怕地陷入了一个很可能很简单的问题,python-3.x,Python 3.x,正在尝试创建密码生成器 无法使if语句正确工作,或者无法知道这是否是解决问题的正确方法。我需要它将每个字母数字表示除以3,如果是整数,则返回a password = input("password: ") password = password.lower() output = [] for character in password: number = ord(character) - 96 output.append(number) x = output if

正在尝试创建密码生成器

无法使if语句正确工作,或者无法知道这是否是解决问题的正确方法。我需要它将每个字母数字表示除以3,如果是整数,则返回a

password = input("password: ")
password = password.lower()
output = []
for character in password:
  number = ord(character) - 96
  output.append(number)

x = output
if x / 3:
  print ("#")

  print (output)
我得到这个错误:
TypeError:只能将列表(而不是“int”)连接到列表

我不知道你想用可被3整除的元素做什么。为了让您开始,这里有一个示例代码。看看这是否有助于你从正确的方向开始

password = input('enter password :').lower()
output = []
for c in password:
    num = ord(c) - 96
    output.append(num)

all_div_by_3 = True
for i in output:
    if i%3 != 0:  #checks if remainder of i/3 is zero. if zero, then divisible, else not divisible.
        all_div_by_3 = False
        break

if all_div_by_3: #is same as if all_div_by_3 == True:
    print ('all divisible by 3')
else:
    print ('all characters are not divisible by 3')
其输出如下:

enter password :cliff
all divisible by 3

enter password :rock
all characters are not divisible by 3

在这里进行了大量阅读和研究之后,很明显我需要使用if、elif和else函数。以下是已完成的项目

password = input("password: ") 
password = password.lower()
output = []
for character in password:
 number = ord(character) - 96
 output.append(number)
for i in output:
 if(i% 3 == 0) :
  print('#', end ="")
 elif(i% 5 == 0) :
  print('%', end ="") 
 else:
  print(chr(i+98), end="")

欢迎来到社区。首先,不要说你在作业上需要帮助,因为这不是家庭作业帮助社区。不要说谢谢之类的话。不需要。最后,到目前为止,这个问题的形式还不完善。试着看看其他问题并学习。放置相关的代码块或完整的代码,并确保您有一个错误或意外的输出,这将使问题集中。现在,这只是一个写得很糟糕的问题。您可以尝试先解决异常,而不是询问整个程序的错误。对于数学问题,试着画一个图表,使逻辑清晰。请修改缩进X是一个列表。您正在尝试将列表除以3。你打算做什么?您是否计划划分[1,2,3]/3?您希望
x/3
做什么?