0

Here is a small terminal-style program I had been working on, but stopped because of issues with the code.(Written in Python 3.4.1) Could anyone help with this?

import time
import sys
import os
#This next part restarts the program in case of invalid user/pass combination
def restart_program():
    python = sys.executable
    os.execl(python, python, * sys.argv)
#definitions of strings in lists
h = 'h'
d = 'd'
ma = 'ma'
me = 'me'
c = 'c'
a = 'a'
l = 'l'
yes = 'yes'
no = 'no'
y = 'yes'
n = 'no'
Yes = 'yes'
No = 'no'
YEs = 'yes'
NO = 'no'
YES = 'yes'
nO = 'no'
yES = 'yes'
yeS = 'yes'
yEs = 'yes'
YeS = 'yes'
#String lists
varList1 = [d,ma,me,c,a,l,h]    
yeS = [yes,y,Yes,YEs,YES,yES,yeS,yEs,YeS]
nO = [no,n,No,NO,nO]
admin = 'admin'
deerfield = 'deerfield'
password = 'password'
cmenasco = 'cmenasco'
cyape = 'cyape'
guest = 'guest'
userList = [cmenasco,cyape,guest]
passList = [admin,deerfield,password]

print('Booting up.....')
print('...............')
print('...............')
print('')
print('')
print('-----LOGIN-----')
TempUser = input('username: ')
TempPassword = input('password: ')

if TempUser == cmenasco:
    if TempPassword == admin:
        print('welcome-Christian-')
        print('------------------')
        time.sleep(2.5)
        print('*-------------------------------------------*')
        print('|         Welcome to SAMNET v1.0!           |')
        print('|       (type in a catagory to view)        |')
        print('|              -documents(d)-|              |')
        print('|                  -mail(ma)-|              |') 
        print('|              -messages(me)-|              |')
        print('|             -classified(c)-|              |')
        print('|            -accountinfo(a)-|              |')
        print('|                 -logout(l)-|              |')
        print('|                   -help(h)-|              |')
        print('|                                           |')
        print('|               c.2013                      |')
        print('*-------------------------------------------*')
        var1 = input('press any key to continue: ')
#Documents
        if var1 == d:
            print('*------------------------------------------*')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('*------------------------------------------*')


#Mail
        elif var1 == ma:
            print('*------------------------------------------*')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('*------------------------------------------*')



#Messages
        elif var1 == me:
            print('*------------------------------------------*')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('*------------------------------------------*')



#Classified
        elif var1 == c:
            print('*------------------------------------------*')
            print('|                                          |')
            print('| 1. report22.txt                          |')
            print('| 2. introd.txt                            |')      
            print('| 3. mason.txt                             |')
            print('| 4. recent_inves.txt                      |')      
            print('| 5. information/about.txt                 |')
            print('| 6. recent_events(rus_com)                |')
            print('| 7. support                               |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('*------------------------------------------*')


#Account Info
        elif var1 == a:
            print('*------------------------------------------*')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')      
            print('|                                          |')
            print('*------------------------------------------*')


#Help


        elif var1 == h:     
            print('*------------------------------------------*')
            print('|                help                      |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('|                                          |')
            print('*------------------------------------------*')






#Logout
        elif var1 == l:
            print('*------------------------------------------*')
            print('|       SAMNET-path/user-cmenasco          |')
            print('|                                          |')
            print('|         Do you want to logout?           |')
            print('|                                          |')
            print('|                                          |')
            print('|******************************************|')
            print('|               Warning!                   |')
            print('|If you logout, session will be terminated!|')
            print('|******************************************|')
            print('|                                          |')
            print('|                                          |')
            print('*------------------------------------------*')
            respondYN = input('(yes/no) ')
            if respondYN == yeS:
                restart_program()
            elif respondYN == nO:






            #make the pages for each link

      #  elif var1 

This is the problem- it says that there is some "Expected indent" or "Unexpected EOF while parsing" -This is the rest of the unfinished program-

elif TempUser == cyape
    if TempPassword == deerfield
        print('success')

if TempUser == guest:
    if TempPassword == password:
        print('success')

if TempUser is not userList or TempPassword is not passList:
    print('incorrect password/username combination')

if TempUser is not userList or TempPassword is not passList:
        restart_program()
  • 1
    why are you starting with `elif` instead if `if`? – Joe T. Boka May 14 '15 at 00:16
  • Im not sure why I did that, Ill try changing it though and see if it makes a difference. I think It was because I have it run sequentially, running down checking each username password combo and so ...Else if it equals the second name instead of the first- kind of like if the first doesnt equal it, then maybe the second one will. I dont think it was really thought through when I put that though. – Christian Menasco May 14 '15 at 00:33
  • Sidenotes: no need to test for all case-combination. use `str.tolower()` or `str.toupper()` and compare with an all-lower or -uppercase string. Also, you really should not have one var for primitive answers. Just use string literals for yes/no. Or wrap the test in a function/method if localization is required (suppose no). Think of usign a function to draw the frames and options (passing a dict of `button:message` would be an idea). Otherwise you will very soon loose overview. – too honest for this site May 14 '15 at 00:49

1 Answers1

1

elif and if are missing colons

elif TempUser == cyape:
    if TempPassword == deerfield:
        print('success')
Ryan
  • 2,058
  • 1
  • 15
  • 29