-2
的名单这是我对我的注册/登录程序当前的代码,我与它有一个问题:我试图alsorts但输入将不被记录,因为我转换列表中的元组
info = []
n = 0
true = "true"
while true == "true":
command = input("What would you like to do?\nLogin or Signup? ")
if "ogin" in command:
loginusername = input("\nWhat is your username? ")
loginpassword = input("What is your password? ")
if (loginusername and loginpassword) in info:
print("\nYou have logged in!\n")
else:
print("\nYou have not signed up!\n")
if "ignup" in command:
usernameinput = input("\nWhat do you want your username to be? ")
info.insert(n, usernameinput)
usernameinput = "false"
passwordinput = input("\nWhat do you want your password to be? ")
info.insert(n, passwordinput)
passwordinput = "false"
print("\n\nYou have successfully signed up!")
n += 1
希望它是。我想它要记录这样为例:
info == [("username1", "password1")]
有没有一种方法可以让我记录下来这样的,因为在目前,该代码记录了这样的数据:
info == ["username1", "password1"]
当然,但用户应该放入什么?名称和密码? – timgeb
请现在添加[mcve] RIght,我不确定你想要做什么。 –
@TomGolledge:编辑过的版本是否也符合你想要达到的目标?看起来这是你需要的 - 从一个数据结构转换到另一个数据结构。 – Tadeck