私の関数では、return文の後にraw_inputを入力してから、私の関数を呼び出します。関数を呼び出すと、raw_inputは完全に無視され、return文だけが機能します。私のreturnステートメントは、Pythonの関数内の残りのコードを無視するのはなぜですか?
def game():
#This selects 5 community cards from the pick_community function
community = pick_community(5)
card_4 = community[3]
card_5 = community[4]
first_3 = community[0:3]
return first_3
river = raw_input("If you are done with the round hit enter:")
try:
if river =="":
return card_4
except:
print "Dont cheat man"
exit()
なぜあなたはそこに 'return'を入れましたか?あなたは関数を返すように言った* –
それは 'return'がすることだからです。 –
すべての関数は最初の 'return'まで実行されます。 – Psytho