Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NameError. Please Help
#1
import sqlite3
con=sqlite3.connect("contactbook.db")
cursor=con.cursor()

def add_contact(group,first_name,last_name,title,mobile):
	cursor.execute("CREATE TABLE IF NOT EXISTS contacts (group TEXT, first_name TEXT, last_name TEXT, title TEXT , mobile INT)")
	con.commit()
	cursor.execute("INSERT INTO contacts VALUES(?,?,?,?,?)",(group,first_name,last_name,title,mobile))
	con.commit()
	group=input("Group:")
	first_name=input("First Name:")
	last_name=input("Last Name:")
	title=input("Title:")
	mobile=int(input("Mobile:"))
	con.close()
def menu():
	try:
		ch1=int(input("[1] - All Contacts\n[2] - Add Contact\n[3] - Edit Contact\n\nChoose One:"))
		if ch1==1:
			all_contacts()
		if ch1==2:
			add_contact(group, first_name, last_name, title, mobile)
		if ch1==3:
			edit_contact()
	except ValueError:
		print("Wrong Format!")


menu()
Error:
[1] - All Contacts [2] - Add Contact [3] - Edit Contact Choose One:2 Traceback (most recent call last): File "asdasdasdasdasd.py", line 29, in <module> menu() File "asdasdasdasdasd.py", line 22, in menu add_contact(group, first_name, last_name, title, mobile) NameError: name 'group' is not defined
Reply


Messages In This Thread
NameError. Please Help - by yusifahmadov - Feb-18-2021, 01:40 PM
RE: NameError. Please Help - by buran - Feb-18-2021, 01:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  NameError: NameError: global name 'BPLInstruction' is not defined colt 7 4,491 Oct-27-2019, 07:49 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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