Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
need help
#1
Hi everyone,i am new to this forum.I need help in my code.i wrote a program for user login and get user details.
I created dic for users and assign gmail id and password as it values.
when we enter the user that not in dict it should create new key and store it
i my program the dict (Users) is not updated every time when i enter new user. please help me on my mistake

here is my code

import turtle

global check_user

users={
"Ram":['[email protected]','111-281-1920'],
"mira":['[email protected]','150-170-1213']
}
check_user=input("Enter name")

for u_keys,u_values in users.items():
if check_user in u_keys:
print(u_values)
else:
print("No user with the name {}" .format(check_user))
break

print("would u like to create an account")
for i in range(2):
x=input("Say yes or NO : ")
if x == "yes":
print("Enter details")
id=input("enter mail id")
phone_no=input("enter phone number")
users.update({check_user:[id,phone_no]})
break
else:
print("thanks for shopping")
break
print(users)
Reply
#2
Put your code between code tags. Here is how.

I hope the emails and the passwords are not real accounts here - in plaint text.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
I have used raw_input as I am still on python 2.7, but that is the only change, and this works, although the two programmed users (Ram and Mira) only have username and password, whereas the new user has name, password and phone number.

global check_user

users={
"Ram":['[email protected]','111-281-1920'],
"mira":['[email protected]','150-170-1213']
}

check_user=raw_input("Enter name: ")

for u_keys,u_values in users.items():
	if check_user in u_keys:
		print(u_values)
	else:
		print("No user with the name {}" .format(check_user))
		break

print("would u like to create an account")
for i in range(2):
	x=raw_input("Say yes or NO : ")
	if x == "yes":
		print("Enter details")
		id=input("enter mail id")
		phone_no=input("enter phone number")
		users.update({check_user:[id,phone_no]})
		break
	else:
		print("thanks for shopping")
		break
print(users)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020