0

I have a problem and it is that my code isn't displaying after the nested statement.

After confirmation.lower == no, it asks the Wrong Info Input and then skips to the Else statement without executing what is in any of the if or elif statements.

confirmation = input("Confirm if information is correct ('yes' or 'no'):")

#confirms if deatils are incorrect
if confirmation.lower() == "no":
    wronginfo = input("Indicate Wrong Info:")
    if wronginfo.lower() == "First Name":

        NewInfo = input(wronginfo+":")
        FirstName = NewInfo
        details()


    elif wronginfo.lower() == "Last Name":

        NewInfo = input(wronginfo+":")
        LastName = NewInfo
        details()


    elif wronginfo.lower() == "Age":
        NewInfo = input(wronginfo+":")
        Age = NewInfo
        details()


   else:
    start = input("Type 'y' to start:")

Note: Details is a function that prints All info such as First Name and last name

4 Answers 4

2

Your problem is that you have wronginfo.lower() == "Last Name": which contains upper case letters and will never be True.

Your options are. Change Last Name to last name

wronginfo.lower() == "last name"

If you would like to keep Last Name then you can use .title(). This will make the first letter of each word a capital and every other letter lower case, which matches what you're trying to compare.

wronginfo.title() == "Last Name"
Sign up to request clarification or add additional context in comments.

Comments

1

You compare string with all characters in lower case to strings that consist upper case letters

Comments

1

This statement can never come up true:

elif wronginfo.lower() == "Last Name":

Your comparison string has upper-case characters; there is no lower-case string that can equal it. Perhaps try this:

elif wronginfo.lower() == "last name":

You will need the same treatment with "First Name" and "Age".

Now, if you like the way your current code reads, simply convert both to lower case like so:

elif wronginfo.lower() == "Last Name".lower():

You get the capitals for program maintenance at the cost of a small amount of CPU time. Since you're working at human typing speeds, that time is not likely to be a problem.

Comments

0

wronginfo.lower() will never equal "First Name" because "First Name" has capital letters in it. Change to

if wronginfo.lower() == "first name":

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.