0

I'm having problems with adding accounts to mapping with function append.

mapp = ["example"]

example1 = raw_input("Enter Username: ")
if example1 in mapp:
    print "yay"
else:
    print ("Forgot Username eh?")
    example = raw_input("Enter New Username: ")
    if example not in mapp:
        mapp.append(sana)

So as you can see from the script, if i enter username "example", program prints "yay". And if i type wrong i can create new "account" what i can use next time when i want my program to print "yay". But when i try to add new "account" it doesn't work. I don't get any error messages or anything but it just doesn't add new "account" to mapp. So any ideas ?

1
  • 1
    Where is the variable sana defined? Commented Jan 28, 2013 at 15:13

1 Answer 1

3

You are not appending the right variable to mapp; you are appending sana but you should have appended example instead:

if example not in mapp:
    mapp.append(example)

For this use-case, you could use a set instead:

mapp = {'example'}

# ...
if example1 in mapp:
    # ...
else:
    # ... 
    example = raw_input("Enter New Username: ")
    mapp.add(example)
Sign up to request clarification or add additional context in comments.

1 Comment

I fixed that. But now it's giving me an error "set object has no attribute 'append'" Can you still help me ? Thanks

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.