2017-04-14 123 views
0

嘿所以我一直在這個事實或敢於蟒蛇遊戲一段時間,我從來沒有得到這個問題之前,但是當我把一個列表它給了我一個語法錯誤,但只有在NAME的名單。而不是實際的清單本身。這裏是代碼:Python - 列表名稱語法錯誤

import random 
import time 
import sys 

dare = ["try to drink a glass of water while standing on your hands", "Let the group deside your dare", "pose in an embarasing pose and take a picture", "kiss the person on your left", "let a person get your phone and text anyone in your contacts.", "do the worm", "lick the floor", "let the group give you a new hairstyle", "drag your butt on the floor and back", "do yoyr best impression of a baby being born", "let someone in the room give you a spanking", "make up a poem about whatever the group comes up with", "make everyone in the room smile", "let someone draw on your face with a pen"] 
d = ["dance with no music for", "curse like a sailor for", "pretend your a clown for", "make up an opera about anyone/anything for", "talk in a different accent for", "break dance for", "do the worm for", "do push ups for", "be someones pet for", "pole dance with an invisible pole for", "sing for", "belly dance for"] 
d_time = ["1 turn", "40 seconds", "3 turns", "25 seconds", "1 minute", "4 turns", "2 minutes", "5 minutes", "5 turns"] 

t = ["who would you want to make out with the most in the room?", "what was the stupidest thing youve ever done?", " if you were an animal, what would you be?", "if you could dye your hair any color, what would it be?", "what was the scariest dream youve had?", "who is the sexiest person here?", "who do you think would actidentaly kill someone in this room?", "who here has the nicest butt?", "how many lovers have you had?", "what is your biggest pet peeve", "who do you have a crush on atm?"] 

print("welcome to Truth or Dare!") 
def begin(): 
    wow = input("[1] Truth, or [2] Dare?") 
    if wow == '2': 
     ch = random.randint(1, 2) 
     if ch == 1: 
      print(random.choice(dare)) 
      time.sleep(1) 
      br = input("did you ([1] chiken out?) or ([2] complete it?)") 
      if br == '1': 
       print("wow...") 
       time.sleep(1) 
       print("thats sad...") 
       time.sleep(1) 
       print("Next player!") 
       time.sleep(1) 
       begin() 
      elif br == '2': 
       print("wow!") 
       time.sleep(1) 
       print("nice!") 
       time.sleep(1) 
       print("Next player!") 
       time.sleep(1) 
       begin() 
     elif ch == 2: 
      print(random.choice(d),(random.choice(d_time)) 
      time.sleep(1) 
      br = input("did you ([1] chiken out?) or ([2] complete it?)") 
      if br == '1': 
       print("wow...") 
       time.sleep(1) 
       print("thats sad...") 
       time.sleep(1) 
       print("Next player!") 
       time.sleep(1) 
       begin() 
      elif br == '2': 
       print("wow!") 
       time.sleep(1) 
       print("nice!") 
       time.sleep(1) 
       print("Next player!") 
       time.sleep(1) 
       begin() 
    elif wow == '1': 
     print(random.choice(t)) 
     time.sleep(1) 
     br = input("did you ([1] chiken out?) or ([2] complete it?)") 
      if br == '1': 
       print("wow...") 
       time.sleep(1) 
       print("thats sad...") 
       time.sleep(1) 
       print("Next player!") 
       time.sleep(1) 
       begin() 
      elif br == '2': 
       print("wow!") 
       time.sleep(1) 
       print("nice!") 
       time.sleep(1) 
       print("Next player!") 
       time.sleep(1) 
       begin() 
begin() 

列表d是得到語法錯誤,請幫助!

+1

你可以發佈完整的Traceback嗎?我無法重現您描述的問題,但是我看到其他一些問題 – JacobIRR

+0

請使用答案旁邊的複選標記表示問題已回答。謝謝! –

回答

0

我認爲問題是:

elif ch == 2: 
     print(random.choice(d),(random.choice(d_time)) # THIS PART!!! 
# You forget to close brackets! > print(random.choice(d),(random.choice(d_time))) 
     time.sleep(1) 
     br = input("did you ([1] chiken out?) or ([2] complete it?)") 
     if br == '1': 
      print("wow...") 
      time.sleep(1) 
      print("thats sad...") 
      time.sleep(1) 
      print("Next player!") 
      time.sleep(1) 
      begin() 

打印(random.choice(d),(random.choice(D_TIME))

此外,你應該使用一個IDE ,IDE告訴你這些基礎錯誤,或者當你忘記關閉某個]或者:。他們爲您節省了大量時間搜索錯誤!

0

你錯過關閉支架「)」在

print(random.choice(d),(random.choice(d_time)) 

,妥善縮進代碼和代碼運行。