Python Forum
I writte 5 functions (def) but on 6 don't work. Someone can help me?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I writte 5 functions (def) but on 6 don't work. Someone can help me?
#1
So I'm learning to program and started with python. I'm training doing a simple rpg game.
Almost all functions use if-else. But one of them does not work.
The console says syntax error and points to the ":"
This is what does not work (I'm Brazilian, only this part is in English for better answers here)
def fight():
    print("You need to choose where look for enemies.Has the 'Cave'")
    global JJ
    JJ = (input("Where loook?")
    if JJ == "Cave":
        print ('Cachaca')
    else:
        print('AAAAAAA')
and that is everything else
import random
print ("Feito por Vinicius Perrud")
print ("Primeiro vamos escolher sua classe, se voce quiser guerreiro digite 1, se quiser arqueiro digite 2")
classe = int(input("Qual classe voce quer ?"))
if classe == 1:
    armas = 1
else: armas = 2
gold = 100
if classe == 1:
    vida = 20
    dano = [0,5]
else:
    vida = 15
    dano = [0,11]
#def commands():
    print('nothing')
def commands():
    print ("Comandos disponiveis sao '1'(loja), '2'(fight), '3'(status).")
    e = int((input("Comando escolhido: ")))
    if e == 1:
        shop()
    elif e==2:
        luta()
    else:
        status()
def shop ():
    print ("Comandos na loja sao '1' (aumenta a vida por 10 de gold), '2' (comprar armas por 10 de gold) e 3(exit)")
    e = int((input("Comando escolhido: ")))
    if e == 1:
        if gold >= 10:
            global gold
            gold = gold - 10
            global vida
            vida = vida + 15
            commands()
        else: commands()
    elif e == 2:
        if gold >= 10:
            global gold
            gold = gold - 10
            global dano
            d = (dano [1]) + 15
            dano [1] = d
            commands()
        else: commands()
def status():
    print("""Vida: {}
    Dano: {}
    Gold: {}""".format(vida,dano,gold))
    commands()
def luta():
    print("You need to choose where look for enemies.Has the 'Cave'")
    global JJ
    JJ = (input("Where loook?")
    if JJ == "Cave":
        print (l)
    else:
        print('AAAAAAA')
commands()
#print (random.triangular(min,max))
Reply
#2
It's missing closing parenthesis on line#54
However, better read https://python-forum.io/Thread-Text-Adve...dictionary
Reply
#3
(Feb-03-2018, 09:47 AM)buran Wrote: It's missing closing parenthesis on line#54
However, better read https://python-forum.io/Thread-Text-Adve...dictionary

Thanks. Look idiot my problem now. :-P
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  User functions don't work: Baldev10 7 3,161 Aug-18-2020, 08:34 PM
Last Post: deanhystad
  Can't work out parameter format for LibVLC functions Domarius 10 5,961 Apr-30-2019, 10:54 PM
Last Post: Domarius

Forum Jump:

User Panel Messages

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