2015-11-24 60 views
-3

在'DisplayBands'函數後面的':'上我得到一個無效的語法錯誤,但是我沒有看到語法錯誤。我可能是盲人。幫助是非常讚賞(請原諒我的愚蠢,我很新的這一點。)語法錯誤,但語法有效?

import time 
import random 

def DisplayBands: 
    print("Guess the name of the band out of:") 
    print("One Dimension") 
    print("Take What?") 
    print("Austin Eabier") 
    print("Front Street Lads") 
    now = time.time() 
    return now 
+2

請重讀如何在Python定義函數... – nneonneo

+1

你需要'()'所以,不,它不是有效的語法 –

回答

0

你必須把()後函數聲明:

def DisplayBands(): 
    print("Guess the name of the band out of:") 
    print("One Dimension") 
    print("Take What?") 
    print("Austin Eabier") 
    print("Front Street Lads") 
    now = time.time() 
    return now 
+0

謝謝這麼多,我是一個白癡:) – ClassyMelon

3

函數定義需要在括號函數名稱的結尾。

def DisplayBands(): 
       ^^ These are required 

在這種情況下,要定義一個函數,0參數