无法在python中接受用户的输入

时间:2018-07-26 07:59:33

标签: python function loops dictionary

我拥有一个使我从用户那里获得价值的功能,并希望将该价值发送给另一个功能进行验证。但是问题是我无法从用户那里获得价值,因为那部分代码没有运行。解释器将我直接带到while循环的其他部分。这是我的代码:

from userAccountDatabase import *
FirstName = ""
LastName = ""
dateOfBirth = ""
userDetails = []

def userDetailsValidation(fieldvalue, fieldName, database):
    for entry in database:
        if fieldName in entry and entry[fieldName] == fieldvalue:
            print("correct value")
            return True
        else:
            return False

def userInputs(FirstName, LastName, dateOfBirth):
    FirstName = str(input("Enter First Name").upper()) # This part of code is not running

    while True:
        if(userDetailsValidation(FirstName, "FirstName", userAccountDetails)) == True:
            userDetails.append(FirstName)
            break
            # directly take me to this
        else:
            print('Enter valid First Name')
            FirstName = str(input("Enter First Name").upper())

userInputs(FirstName, LastName, dateOfBirth)

0 个答案:

没有答案