-3

does anyone know why this isn't working? I trided to make a program that you register, it saves the password and username in to a file and then you login to it. I didn't finish it as you can see in the login class but I ran in to an error:

File "user.py", line 114
login()
    ^
IndentationError: expected an indented block

I don't really know what the error means. sorry when I pasted the code it removed the spaces...

import os
import time
from os.path import exists
import sys   #import all the stuff

def cls():          #define class cls for "clear screen"
   print("\n"*100)






def login():       #definr class login
  print("lolo")







def register():     #define register
    username_registered = input("type username:")    #asks for a username

    print("your username is", username_registered)    #print's out the      username



    username_file = open("username.txt", 'w')

    username_file.write(username_registered)         #writes username to file




    password_registered = input("type password:")       #asks for a password

    print("your password is", password_registered)



    password_file = open("password.txt", 'w')

    password_file.write(password_registered)         #saves the password
    menu()












print("this is a program that you register, it saves the registration, then you login")
os.system("pause")
                        #draws the menu
print("""                       
----------------------- 
menu
-----------------------
1) forward
2) exit
-----------------------
""")


decision = input("what is your decision:")  #asks for a decision


if(decision != "1" and decision != "2"): #if you tipe something else than 1  or 2 it exits
    print("error, exiting")
    time.sleep(2)
    cls()
    sys.exit(1)


if(decision == "2"):    #if you chose 2 it exits
    sys.exit(1)

x = 0

while(x != 100):             #draws the loading
    print("loading", x, "%")
    x = x + 1
    time.sleep(0.01)


time.sleep(0.05)
print("loading", x, "%") #draws the remaning 100th percent

time.sleep(1)     #waits a bit 


def menu():
    print("""
    -------------------------
    menu2
    -------------------------
    1) login
    2) register
    3) exit
    --------------------------
    """)                            #prints the menu2

    decision = input("what's your decision:") #asks fr a decision

    if(decision == "1"):    #calls login if you tiped 1
        login()

    elif(decision == "2"):   #calls register if you tiped 2
        register()

    elif(decision == "3"):     #exits if you tiped 3
        sys.exit(1)

    else:                       #terminates if you tiped anything else 
        print("error terminating")
    time.sleep(2)
    sys.exit(1)

    menu()  #calls the menu       
jakic
  • 23
  • 7
  • 4
    You need to learn the basics of Python syntax. (in particular, indentation) – SLaks Apr 14 '16 at 16:54
  • Python uses indentation to help structure code into [blocks](https://en.wikipedia.org/wiki/Block_%28programming%29). Your code has no indentation, the interpreter senses that, and as a result the program fails. – Conduit Apr 14 '16 at 17:00
  • 1
    The error tells you you need indentation. What is not clear about that? This is literally the first thing mentioned in any Python tutorial. – Daniel Roseman Apr 14 '16 at 17:00

1 Answers1

2

Code blocks in python must be indented. For example, for the cls function you've written:

def cls():
    print("\n"*100)
emibloque
  • 195
  • 1
  • 3