- Joao:
- Posts : 12
Points : 2435
Reputation : 4
Join date : 2017-10-03
[PYTHON] Change the ID with a new user
Wed Oct 04, 2017 2:08 pm
A simple code ( very simple ) to change the actual ID, to the next, when a new user enter, here's the code:
Aint THAT thing, but it can be usefull
- Code:
"""
CHANGING ACTUAL ID """
ID_Actual = 0
while 1:
User_Actual = input('Type the username: ')
User_ID_Actual = ID_Actual
print('USER: {}'.format(User_Actual))
print('ID: {}'.format(User_ID_Actual))
ID_Actual = User_ID_Actual + 1
continue
Aint THAT thing, but it can be usefull
Re: [PYTHON] Change the ID with a new user
Wed Oct 04, 2017 2:24 pm
Great, for advanced login system, would be nice to add the time module, and use it before the ID changes.
- Code:
import time
time.sleep(1)
- Joao:
- Posts : 12
Points : 2435
Reputation : 4
Join date : 2017-10-03
Re: [PYTHON] Change the ID with a new user
Wed Oct 04, 2017 2:43 pm
Renan Araújo wrote:Great, for advanced login system, would be nice to add the time module, and use it before the ID changes.
- Code:
import time
time.sleep(1)
And if I add a name that already exists ? Is there a way to refuse the user ?
Re: [PYTHON] Change the ID with a new user
Wed Oct 04, 2017 2:54 pm
Joao wrote:Renan Araújo wrote:Great, for advanced login system, would be nice to add the time module, and use it before the ID changes.
- Code:
import time
time.sleep(1)
And if I add a name that already exists ? Is there a way to refuse the user ?
You could use a var with the registered users
- Code:
users = []
- Code:
newuser = input("Type a new username: ')
if newuser in users:
print('User already exists !')
break ( if you are using a while loop)
- Joao:
- Posts : 12
Points : 2435
Reputation : 4
Join date : 2017-10-03
Re: [PYTHON] Change the ID with a new user
Wed Oct 04, 2017 3:19 pm
Thanks !
Permissions in this forum:
You cannot reply to topics in this forum
|
|