Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
variable gets lost
#1
why doesn't this work??
admin = ['Jordy', 'Julian']
logged_in = 0

def login(name):
    for i in admin:
        if name == i:
            print("Welcome in the system " + name)
            logged_in = 1
            break
    else:
        print('you are not an admin')

def set_user():
    if logged_in == 1:
        setu = 1
        if setu == 1:
            setu += 1
            print('we need some data')
            lastname = input('what is your lastname ')

login(input('fill in your name '))
set_user()

it results in this error:
Error:
Traceback (most recent call last):  File "python", line 24, in <module>  File "python", line 14, in set_user NameError: name 'logged_in' is not defined
Reply


Messages In This Thread
variable gets lost - by Jordy - Oct-10-2016, 05:47 PM
RE: variable gets lost - by ichabod801 - Oct-10-2016, 06:03 PM
RE: variable gets lost - by Jordy - Oct-10-2016, 07:15 PM
RE: variable gets lost - by ichabod801 - Oct-10-2016, 07:32 PM
RE: variable gets lost - by Jordy - Oct-10-2016, 07:34 PM
RE: variable gets lost - by ichabod801 - Oct-10-2016, 07:36 PM
RE: variable gets lost - by Jordy - Oct-10-2016, 07:42 PM
RE: variable gets lost - by sparkz_alot - Oct-10-2016, 07:51 PM
RE: variable gets lost - by Mekire - Oct-10-2016, 07:56 PM
RE: variable gets lost - by sparkz_alot - Oct-10-2016, 08:06 PM
RE: variable gets lost - by Yoriz - Oct-10-2016, 08:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Lost Control over VLC jrockow 8 1,119 Jul-18-2023, 06:04 PM
Last Post: jrockow
  Lost Modules standenman 2 754 Jun-22-2023, 12:18 PM
Last Post: standenman
  Lost Module standenman 10 2,904 Oct-30-2021, 05:11 PM
Last Post: deanhystad
  XML Editing formatting lost ateestructural 2 1,935 Apr-08-2021, 04:41 AM
Last Post: ndc85430
  List structure lost when multiplying Protonn 2 2,272 Apr-23-2020, 04:16 AM
Last Post: buran
  lost dictionary jjpy 1 1,910 Jul-10-2019, 12:19 PM
Last Post: scidam

Forum Jump:

User Panel Messages

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