2017-04-14 124 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)) 

,妥善缩进代码和代码运行。