Ask coding questions

← Back to all posts
1
What is wrong with my code?

I am trying to make a simple login (pretty much a DB) in python, the register works fine, it grabs the user and password, turns it into the user:pass format, and shoves it in the combolist.txt.

But when i try and login with the said user:pass, it fails.

REPL Link: https://repl.it/@AzureScripts/Simple-Database

Commentshotnewtop
1

You forgot to add + \n to the end of line 12. The reason it doesn't work is because line 12 is testing for a string and can't find it because the actual string has \n on the end (which was added in line 28).

The correct code on line 12 is

combo = user + ':' + passw + '\n'
1

@Geocube101 I just did something a lot simpler

at the top of the script, i should've done

combolist = open('combolist.txt').read().splitlines()

that single line fixed my issue.

1

However, I do want to add a way to stop people from using the same username as another person.

I tried to do "if wanted_user in combolist:
print("username is taken!")"

but that doesn't seem to work.