Can you please check my program

Everything is working but log() is not working properly

def select ():
    print('''
————————————————————————————
1) login
2) signin 
————————————————————————————
''')
    a=int(input('enter here: '))
    
    if a==1:
     log()
    if a==2:
     sig()
    else:
     print('invalid input')
     select ()

def sig():
    s=input ('enter name: ')
    t=input ('enter password : ')
    use()

def log():
    c=input ('enter name: ')
    d=input ('enter password : ')
    
    if 'c'=='s' and 'd'=='t':
     use()
    else:
     print('invalid input or you are not signing')
     select ()

def use():
    print('''
hello''')
    print('''
————————————————————————————
1) mail
2) logout 
————————————————————————————
''')
    z=int(input('enter here: '))
    if z==1:
     print('no mail received ')
     use()
    if z==2:
     select ()
    else:
     print('invalid input ')
     use()

select ()

This will obviously always evaluate to False. Did you mean to do if c=='s' and d=='t'?

Did this to still not working

What isn’t working? What is your expected result and what are you getting instead?

I am expecting it will take me to use function but it is
printing else function

That’s because this:
'c'=='s' and 'd'=='t'
is always False, like a said above. If you change it to
c=='s' and d=='t'
and enter s and t when prompted for username/password, the use() function will be called.

I have changed it but still not working

Sure it does. I tested it and it works as expected:

————————————————————————————
1) login
2) signin 
————————————————————————————

enter here: 1
enter name: s
enter password : t

hello

————————————————————————————
1) mail
2) logout 
————————————————————————————

enter here: 1
no mail received 

hello

————————————————————————————
1) mail
2) logout 
————————————————————————————

enter here: 

If you expect something else, you will have to specify what it is you want to do.

1 Like

:joy::joy::joy:
s and t value from here what I meant

Functions can’t see variables defined in other functions. To make the s and t variables accessible from within log, you will need to do one of the following:

  1. Pass them in as arguments to log
  2. Store them in global variables
  3. Create a class and make s and t instance attributes

Additionally, you must ensure that sig is called before log, since the latter requires data from the former.

Ok
thanks for helping and being so patient :yellow_heart: