如何创建一个验证函数,使用户输入不重复?

2024-09-28 19:21:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要帮助,使验证功能,以帮助我得到一个错误输出时,用户输入重复

这只是我正在做的代码的一部分,我只需要帮助创建一个验证函数

Color_ID_List=[]
maxColorList=15
while len(Color_ID_List)<maxColorList:
    b=input("Enter New color: ")
    c=int(input("Enter ID: "))
    d=input("Enter type of color: ")
    print("The ID of", b, "is", c,"and the type of color is",d)
    Color_ID_List.append(b)
    Color_ID_List.append(c)
    Color_ID_List.append(d)

print("")
print("")
print("The following colors and ID has been added")
print(Color_ID_List)

Tags: andofthe功能idinputistype