Ok, so I tried running my code (so far) and it has this annoying/weird error. I have double-checked it but it is still wrong. I know it’s usually to do with indents, but everything seems to be in order. I’ll paste the WHOLE code down there. PS some things have hashtags, and so are not active – they are comments.
import time, sys
from os import system, name
from termcolor import colored
from random import randint
from time import sleep
Red = "\033[0;31m"
Green = "\033[0;32m"
Orange = "\033[0;33m"
Blue = "\033[0;34m"
Purple = "\033[0;35m"
Cyan = "\033[0;36m"
White = "\033[0;37m"
rep = 0
money = 0
sleep1 = randint(1, 6)
def main():
ch = input("")
if ch == "1":
#1()
elif ch == "2":
#2()
elif ch == "3":
#3()
elif ch == "4":
#4()
elif ch == "5":
exit()
else:
setup_main()
def setup_main():
clear()
sleep(1)
print_slow(Green+"Reputation: "+str(rep))
print_slow(Green+"\nBritish Pounds: "+str(money))
print()
print_slow(White+"\nAbilities:")
print_slow(Orange+"\n[1] Let People On")
print_slow(Orange+"\n[2] Buy Items")
print_slow(Orange+"\n[3] Stamp Tickets")
print_slow(Orange+"\n[4] Sell Tickets")
print_slow(Orange+"\n[5] End Game")
main()
def print_slow(str):
for letter in str:
sys.stdout.write(letter)
sys.stdout.flush()
time.sleep(0.05)
def clear():
if name == 'nt':
_ = system('cls')
else:
_ = system('clear')
def play_intro():
print_slow(colored("The Times:", 'red', attrs=['blink']))
print_slow(colored("\nThis is the week of bad luck! All the Train's Conductors have gone on strike! This is the week of need! The overground stations are looking for people that can mark tickets, and decide whether civilians are let in. Some terrorists have tried to sneak in countless times and no one has been able to stop them. If you join you will make a huge difference to our country!", 'red', attrs=['blink']))
print_slow(colored("\nšš ššŖššøš» š£š®š»š»š ššŖš¶š²š·š®", 'red', attrs=['blink']))
input("\n>")
#For those forking this project, this is about making it different colours! =P
#text = colored("Hello, World!", 'red', attrs=['blink'])
def start():
print_slow(colored("Hello and Welcome to 'Ticket Master'!", 'cyan', attrs=['blink']))
print_slow(colored("\nHINT: Whenever you see the '>' symbol press Enter", 'cyan', attrs=['blink']))
input("\n>")
clear()
print_slow(colored("Ok good job!\n", 'cyan', attrs=['blink']))
print_slow(colored("Would you like to start the Introduction? (y/n)\n", 'cyan', attrs=['blink']))
Intro = input("")
if Intro == "y":
print_slow(colored("Ok, directing you to the intro...\n", 'cyan', attrs=['blink']))
sleep(sleep1)
clear()
play_intro()
else:
print()
clear()
print_slow("Enter a name:")
nad = input(Purple+"\nConductor ")
name = "Conductor "+nad
print_slow(White+"Nice to meet you "+Purple+name+White+"! It's time for you to start your new job!")
input("\n>")
sleep(2)
setup_main()
start()
>Solution :
Replace your comments in line 23 – 30 with the pass
keyword (or just add it after the comment). The body of your if conditions can’t be empty. pass
acts as a placeholder for code to be implemented later.
Something like this:
def main():
ch = input("")
if ch == "1":
#1()
pass
elif ch == "2":
#2()
pass
elif ch == "3":
#3()
pass
elif ch == "4":
#4()
pass
elif ch == "5":
exit()
else:
setup_main()