Registration (simple version)

A very simple registration script. It asks you for a username, checks whether the username already exists in the users.csv file before asking you for a password and 'registering' you (by storing your username and password). Simples.

import csv
USERSFILE = 'users.csv'

users = csv.csv2sequence(USERSFILE)

valid = False
while not valid:
  username  = input('Select username            : ')
  clash = False
  for user in users:
    if username == user[0]:
      print('Username already in use - try again')
      clash = True
  if not clash:
    password = input('Set a password             : ')
    users.append([username,password])
    csv.sequence2csv(users,USERSFILE)
    valid = True

I've provide you with this script, a csv handling library (mine, not Pythons) and a sample users.csv file.
ċ
csv.py
(1k)
Mark Mills,
18 Apr 2020, 14:10
ċ
Mark Mills,
18 Apr 2020, 14:10
ċ
Mark Mills,
18 Apr 2020, 14:09