用Python写班级花名册(含添加、删除、修改、查询等)

print(“欢迎使用花名册系统v6.8”.center(50))
print(“1:添加新名字”)
print(“2:删除一个名字”)
print(“3:修改一个名字”)
print(“4:查询一个名字,显示此人序号”)
print(“5:输出班级名单”)
print(“6:统计班级人数”)
print(“7:退出系统”)
print("="*60)
NameList=[‘A’,‘B’,‘C’,‘D’,‘E’,‘F’,‘G’]

while True:
num = int(input(“输入数字”))
if num1:
name = input(“输入名字”)
if name in NameList:
print(“名字已经存在”)
else :
NameList.append(name)
print(“添加成功”)
elif num
2:
name = input(“输入名字”)
if name in NameList:
NameList.remove(name)
print(“删除成功”)
else:
print(“名字不存在”)
elif num3:
name = input(“输入要修改的名字”)
if name in NameList:
name1= input(“输入修改成的名字”)
NameList[NameList.index(name)]=name1
print(“修改成功”)
else:
print(“无法修改,名字不存在”)
elif num
4:
name = input(“输入名字”)
if name in NameList:
print(NameList.index(name))
else:
print(“名字不存在”)
elif num5:
print(NameList)
elif num
6:
print(set(NameList))
elif num==7:
print(“退出”)
break;
print(“已退出”)

你可能感兴趣的:(用Python写班级花名册(含添加、删除、修改、查询等))