what is wrong with this code

#This is not free source
#Don't cheat by looking @ this
#If you do you ruin the game

#A Towel Production
# APOC
#-------

global ammo1
global ammo2
global ammo3
global health
global tech_parts
global exp
global radio_parts
ammo1=10
ammo2=0
ammo3=0
health=100
tech_parts=0
exp=0
radio_parts=0
def simpstart():
    print "You wake in a haze. A crate,a door and a radio."
    g1 = raw_input("Which do you choose")
    if g1 == "CRATE" or g1 == "Crate" or g1 == "crate":
        print "There is a pack of ammo,some food and an odd microchip"
        ammo1=ammo1+6
        health=health+10
        tech_parts=tech_parts+1
    elif g1 =="DOOR" or g1 == "Door" or g1 == "door":
        print "You are outside"
    elif g1 == "RADIO" or g1 == "Radio" or g1 == "radio":
        print "It's only a few parts"
        radio_parts=radio_parts+3
    g2 = raw_input("So this is NYC.Ten years after.There are a few streets.Go west or north"
    if g2 == "WEST" or g2 == "West" or g2 == "west"
        path_1()
    elif g2 == "NORTH" or g2 == "North" or g2 == "north":
        path2()
def path_1():
    print "This is where it all started. Freedom Tower. A biotech firm called Aesthos Biotechnology. Based here."
    print "I worked there."
    1 = raw_input("Go in or stay out")
    if 1 == "GO IN" or 1 == "Go in" or 1 == "go in":
        2 = raw_input

Dani AI

Generated

Brief, practical summary for (and anyone reading): the immediate SyntaxError IDLE reports (line 38) is almost always a missing token — check the raw_input / if area for a missing closing parenthesis or a missing colon. Beyond that there are classic Python mistakes that will bite you later: invalid variable names like 1 = ..., assigning to module variables inside a function without declaring them global (which causes UnboundLocalError), and calling undefined functions (e.g. path2() vs path_1() mismatches). is right that several lines are nonsensical, and is right to ask for the full traceback — that makes pinpointing the error trivial.

Concrete things to fix first

  • Fix the missing ) or : reported by the traceback; one syntax error prevents the rest of the file being parsed.
  • Replace any assignments to numeric names (e.g. 1 = ...) with proper identifiers.
  • If you assign to ammo1, health, etc. inside a function, either declare them global at the top of that function or, better, keep state in a single object/dict or a Player class.
  • Normalize input instead of many or comparisons: use .strip().lower() and compare against lowercase values.
  • Make sure every called function (like path2) is actually defined.

A small pattern that avoids globals (Python 2 shown; for Python 3 use input() and print()):

state = {'ammo': 10, 'health': 100, 'parts': 0, 'radio': 0}

def choose(state):
    choice = raw_input("Which do you choose? ").strip().lower()
    if choice == 'crate':
        state['ammo'] += 6
        state['health'] += 10
        state['parts'] += 1
    elif choice == 'radio':
        state['radio'] += 3

Debugging workflow: fix one syntax error at a time, run the file after each small change, read the full traceback and post it if stuck, and use an editor with syntax highlighting/linting. After syntax is clean, refactor globals into a single state object or a class to avoid scope bugs.

Recommended Answers

All 4 Replies

At least the lines 11 to 17 do not make any sense and should be deleted. Lines 46 - 48 are worse. You can not change the meaning of numbers by assignment. Shortly: everything is wrong.

actually, mr.fancy pymod, IDLE says the error is on line 38

look at the full traceback record. and it's better to post the full traceback here...

Line 38 is clearly one of the many syntax errors. You should show some kind of effort, start small, test, add lines. Scratch this code as after syntax errors it still has the poor design, honestly. It is trying to use, with wrong syntax, global variables, which is bad design. It is hard coding the text inside the code and the map of the adventuture universe into if statements instead of in data. It goes on. Start again to avoid lot of problems later.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.