2012-09-28 5 views
0

나는 최근에이 모든 도움 덕분에이 프로그램을 실행할 수 있었지만 내 프로그램이 여기서 끝나는 이유를 알 수 없습니다. 그것을보고, if answer == 3: 그냥 다음 만남에 데려다,하지만 내 프로그램이 닫힙니다. 내가 놓친 게 있니? 내 프로그램이 일찍 끝나는 이유는 무엇입니까?

# First Encounter (main program really) 
def fi_en(): 
    global pow, cun, per 
    print""" 
It smells of damp vegetation, and the air is particularly thick. You can 
hear some small animals in the distance. This was a nice place to sleep. 

1. Stay close, find some cover, and wait for food to show up. 

2. Explore the nearby marsh & find the nearest river, following it downstream. 

3. Walk towards the large mysterious mountain in the distance. 
""" 
    answer = int(raw_input(prompt)) 
    if answer == 1: 
     cun_one = roll_3d6() 
     if cun_one <= cun - 2: 
      print"""Time passes as eventually you capture some varmints. 
You feel slightly more roguish.""" 
      cun = cun + 1 
      fi_en() 
     else: 
      print """Time passes and a group of slavers marches into right 
where you are hiding in the woods. They locate you, capture you, and haul you 
away for a lifetime of servitude in the main city. 
Goodbye %s""" % name 
    elif answer == 2: 
     power = roll_3d6() 
     if power <= pow - 4: 
      print"""You trudge through the marshes until you eventually reach 
a large river. Downstream from the river is a large temple covered in vines, 
you walk towards it. You feel more powerful.""" 
      pow = pow + 2 
      te_en() 
     else: 
      print """The vegetation here wraps itself around your legs making 
it impossible to move. You will most likely die here in the vegetation. 
Goodbye %s.""" % name 
    elif answer == 3: 
     cun_two = roll_3d6() 
     if cun_two <= cun: 
      print """You make your way towards the mountain and you encounter 
a really large group of devil dogs guarding the entrance to the mountain.""" 
      dd_en() 
    else: 
     print"You have gotten lost and ended up right where you started." 
     fi_en() 

그리고 내 출력은 다음과 같습니다 당신이 악마의 개들이 정말 큰 그룹을 놓치고처럼

It smells of damp vegetation, and the air is particularly thick. You can 
hear some small animals in the distance. This was a nice place to sleep. 

1. Stay close, find some cover, and wait for food to show up. 

2. Explore the nearby marsh & find the nearest river, following it downstream." 

3. Walk towards the large mysterious mountain in the distance. 

> 3 
Raymond-Weisss-MacBook-Pro:lod Raylug$ 
+4

그것들은 ... cun_two> cun이면 아무 것도 인쇄하지 않을 것입니다. –

+0

'cun' 변수는 무엇입니까? –

+0

@JoranBeasley와 동의 :'else' 블록을 들여 쓰기로 한 번 더 들여다 보면'if cun_two <= cun :'의 레벨이됩니다. –

답변

1

어디에서나 전역을 정의하지 않았습니다. 조건 3에는 "else"문이 없으므로 cun_one이 정의되지 않은 cun 변수보다 작거나 같지 않으므로 answer == 3 일 때 수행 할 작업이 없습니다.

+0

감사합니다. @sellikesybok 및 그 밖의 모든 사람들! – lerugray

2

그것은 나에게 소리. 이 문제를 해결 하시겠습니까?

1

이미 작동 했으므로 모든 항목이 삭제되었습니다. , 단지 코멘트.

입력이 자동으로 int가되기 때문에 input ('Prompt')을 사용할 수 있습니다. raw_input은 입력을 문자열로 변환 한 다음 해당 문자열을 필요하지 않은 int로 변환합니다.

관련 문제