0
私はあなたがサッカー(サッカー)の統計を書くプログラムを設計しました。それは働いていますが、私はそれに続くprommenを引き起こす関数を終了するオプションを追加しました。もしあなたが少なくとも一度はstatを書くのであれば、それはクラッシュするでしょう。だから私はそれを修正しましたが、今はそれを実行しようとするとカウントが始まりますが、カウントも0になります。入出力のプログラムがpythonで正しい整数を出力しない3
pk_range_goal = range(0, 1000)
pk_list_goal = list(pk_range_goal)
pk_input = '''goal/saved/missed
'''
def body():
while True:
choice = input("")
first_number_pk_goal = pk_list_goal[0]
integer_pk_number_goal = int(first_number_pk_goal)
if choice == "pk":
good_bad_input_pk = input(pk_input)
if good_bad_input_pk == "goal":
pk_list_goal.remove(first_number_pk_goal)
integer_pk_number_goal = int(first_number_pk_goal)
string_number_pk_goal = str(first_number_pk_goal)
print("Penalty Kick goal(s): ", string_number_pk_goal)
elif choice == "q":
print("Are you sure that you want to finish the stat counting? (yes/no)")
quit_choice = input()
if quit_choice == "yes":
if integer_pk_number_goal >= 1:
print("Penalty Kick goal(s): ", string_number_pk_goal)
elif integer_pk_number_goal == 0:
print("Penalty Kick goal(s): 0")
else:
pass
break
else:
pass
body()
EDIT:私は1から開始する範囲を作ってみましたが、その後、あなたはそれを書く必要があるだろうここで私は、ここでのコードの1000行の上にペーストをコピーするunappropriateだろう考え出しとして一つだけのstatのです二回の完全なソースコードで2
コンプリート
# -----> * INTRODUCTION * <-----
Commands = ''' STAT ------------> COMMAND
Penalty Kick -----> pk
-> Goal ----------> goal
-> Saved ---------> saved
-> Missed --------> missed
Free Kick --------> fk
Corner Kick ------> ck
Throw In ---------> ti
Cross ------------> cross
-> Good Delivery -> gd
-> Good Delivery -> pd
1 versus 1 ------> 1v1
-> Won ----------> w
-> Lost ---------> l
Shot ------------> shot
Header ----------> header
-> On Target ----> on target
-> Off Target ---> off target
Save ------------> save
To quit press q
'''
print(Commands)
# -----> * Penalty Kicks Variables * <-----
pk_range = range(0, 1000)
pk_list = list(pk_range)
pk_range_goal = range(0, 1000)
pk_list_goal = list(pk_range_goal)
pk_range_saved = range(0, 1000)
pk_list_saved = list(pk_range_saved)
pk_range_missed = range(0, 1000)
pk_list_missed = list(pk_range_missed)
pk_input = '''goal/saved/missed
'''
# -----> * Free Kicks Variables <-----
fk_range = range(0, 1000)
fk_list = list(fk_range)
fk_range_gd = range(0, 1000)
fk_list_gd = list(fk_range_gd)
fk_range_pd = range(0, 1000)
fk_list_pd = list(fk_range_pd)
fk_input = '''gd/pd
'''
# -----> * Corner Kicks Variables * <-----
ck_range = range(0, 1000)
ck_list = list(ck_range)
ck_range_gd = range(0, 1000)
ck_list_gd = list(ck_range_gd)
ck_range_pd = range(0, 1000)
ck_list_pd = list(ck_range_pd)
ck_input = '''gd/pd
'''
# -----> * Throw Ins Variables * <-----
ti_range = range(0, 1000)
ti_list = list(ti_range)
ti_range_gd = range(0, 1000)
ti_list_gd = list(ti_range_gd)
ti_range_pd = range(0, 1000)
ti_list_pd = list(ti_range_pd)
ti_input = '''gd/pd
'''
# -----> * Crosses Variables * <-----
crosses_range = range(0, 1000)
crosses_list = list(crosses_range)
crosses_range_gd = range(0, 1000)
crosses_list_gd = list(crosses_range_gd)
crosses_range_pd = range(0, 1000)
crosses_list_pd = list(crosses_range_pd)
crosses_input = '''gd/pd
'''
# -----> * 0 vs 0 Variables * <-----
v1_range = range(0, 1000)
v1_list = list(v1_range)
v1_range_w = range(0, 1000)
v1_list_w = list(v1_range_w)
v1_range_l = range(0, 1000)
v1_list_l = list(v1_range_l)
v1_input = '''w/l
'''
# -----> * Shots Variables * <-----
shots_range = range(0, 1000)
shots_list = list(shots_range)
shots_range_gd = range(0, 1000)
shots_list_gd = list(shots_range_gd)
shots_range_pd = range(0, 1000)
shots_list_pd = list(shots_range_pd)
shots_input = '''on target/off target
'''
# -----> * Headers Variables * <-----
headers_range = range(0, 1000)
headers_list = list(headers_range)
headers_range_gd = range(0, 1000)
headers_list_gd = list(headers_range_gd)
headers_range_pd = range(0, 1000)
headers_list_pd = list(headers_range_pd)
headers_input = '''on target/off target
'''
# -----> * Saves Variables * <-----
saves_range = range(1, 1000)
saves_list = list(saves_range)
# -----> * Long Pass Variables * <-----
long_passes_range = range(1, 1000)
long_passes_list = list(long_passes_range)
long_passes_range_first_touch = range(1, 1000)
long_passes_list_first_touch = list(long_passes_range_first_touch)
long_passes_range_second_touch = range(1, 1000)
long_passes_list_second_touch = list(long_passes_range_second_touch)
long_passes_input = '''first touch/second touch
'''
# -----> * Main Function * <-----
def body():
while True:
choice = input("")
# -----> * Penalty Kicks Goal Variables * <-----
# -----> * Penalty Kicks Missed Variables * <-----
first_number_pk_missed = pk_list_missed[0]
integer_pk_number_missed = int(first_number_pk_missed)
number_pk_missed = integer_pk_number_missed - 1
string_number_pk_missed = str(number_pk_missed)
# -----> * Penalty Kicks Saved Variables * <-----
first_number_pk_saved = pk_list_saved[0]
integer_pk_number_saved = int(first_number_pk_saved)
number_pk_saved = integer_pk_number_saved - 1
string_number_pk_saved = str(number_pk_saved)
# -----> * Total Penalty Kicks Variables * <-----
first_number_pk = pk_list[0]
integer_pk_number = int(first_number_pk)
number_pk = integer_pk_number - 1
string_number_pk = str(number_pk)
# -----> * Penalty Kicks Function * <-----
first_number_pk_goal = pk_list_goal[0]
integer_pk_number_goal = int(first_number_pk_goal)
if choice == "pk":
good_bad_input_pk = input(pk_input)
if good_bad_input_pk == "goal":
integer_pk_number_goal = 0
string_number_pk_goal = str(first_number_pk_goal)
pk_list_goal.remove(first_number_pk_goal)
print("Penalty Kick goal(s): ", string_number_pk_goal)
elif good_bad_input_pk == "saved":
print("Penalty Kick(s) saved: ", string_number_pk_saved)
elif good_bad_input_pk == "missed":
print("Penalty Kick(s) missed: ", string_number_pk_missed)
else:
pass
print("Penalty Kick(s) : ", string_number_pk)
# -----> * Free Kicks with Good Delivery Variables * <-----
first_number_fk_gd = fk_list_gd[0]
integer_fk_number_gd = int(first_number_fk_gd)
number_fk_gd = integer_fk_number_gd - 1
string_number_fk_gd = str(number_fk_gd)
# -----> * Free Kicks with Poor Delivery Variables * <-----
first_number_fk_pd = fk_list_pd[0]
integer_fk_number_pd = int(first_number_fk_pd)
number_fk_pd = integer_fk_number_pd - 1
string_number_fk_pd = str(number_fk_pd)
# -----> * Free Kicks Variables * <-----
first_number_pk = pk_list[0]
integer_pk_number = int(first_number_pk)
number_pk = integer_pk_number - 1
string_number_pk = str(number_pk)
# -----> * Free Kicks Function * <-----
if choice == "fk":
good_bad_input_fk = input(fk_input)
if good_bad_input_fk == "gd":
print("Free Kick(s) with a Good Delivery: ", string_number_fk_gd)
elif good_bad_input_fk == "pd":
print("Free Kick(s) with a Poor Delivery: ", string_number_fk_pd)
else:
pass
print("Free Kick(s)", string_number_fk)
# -----> * Corner Kick Variables * <-----
elif choice == "ck":
good_bad_input_ck = input(ck_input)
if good_bad_input_ck == "gd":
first_number_ck_gd = ck_list_gd[0]
ck_list_gd.remove(first_number_ck_gd)
number_ck_gd = ck_list_gd[0]
string_number_ck_gd = str(number_ck_gd)
print("Corner Kick(s) with a Good Delivery: ", string_number_ck_gd)
elif good_bad_input_ck == "pd":
first_number_ck_pd = ck_list_pd[0]
ck_list_pd.remove(first_number_ck_pd)
number_ck_pd = ck_list_pd[0]
string_number_ck_pd = str(number_ck_pd)
print("Corner Kick(s) with a Poor Delivery: ", string_number_ck_pd)
else:
pass
first_number_ck = ck_list[0]
ck_list.remove(first_number_ck)
number_ck = ck_list[0]
string_number_ck = str(number_ck)
print("Corner Kick(s): ", string_number_ck)
# -----> * Throw Ins Functions * <-----
elif choice == "ti":
good_bad_input_ti = input(ti_input)
if good_bad_input_ti == "gd":
first_number_ti_gd = ti_list_gd[0]
ti_list_gd.remove(first_number_ti_gd)
number_ti_gd = ti_list_gd[0]
string_number_ti_gd = str(number_ti_gd)
print("Throw In(s) with a Good Delivery: ", string_number_ti_gd)
elif good_bad_input_ti == "pd":
first_number_ti_pd = ti_list_pd[0]
ti_list_pd.remove(first_number_ti_pd)
number_ti_pd = ti_list_pd[0]
string_number_ti_pd = str(number_ti_pd)
print("Throw In(s) with a Poor Delivery: ", string_number_ti_pd)
else:
pass
first_number_ti = ti_list[0]
ti_list.remove(first_number_ti)
number_ti = ti_list[0]
string_number_ti = str(number_ti)
print("Throw In(s): ", string_number_ti)
# -----> * Crosses Function * <-----
elif choice == "cross":
good_bad_input_crosses = input(crosses_input)
if good_bad_input_crosses == "gd":
first_number_crosses_gd = crosses_list_gd[0]
crosses_list_gd.remove(first_number_crosses_gd)
number_crosses_gd = crosses_list_gd[0]
string_number_crosses_gd = str(number_crosses_gd)
print("Cross(es) with a Good Delivery: ", string_number_crosses_gd)
elif good_bad_input_crosses == "pd":
first_number_crosses_pd = crosses_list_pd[0]
crosses_list_pd.remove(first_number_crosses_pd)
number_crosses_pd = crosses_list_pd[0]
string_number_crosses_pd = str(number_crosses_pd)
print("Cross(es) with a Good Delivery: ", string_number_crosses_pd)
else:
pass
first_number_crosses = crosses_list[0]
crosses_list.remove(first_number_crosses)
number_crosses = crosses_list[0]
string_number_crosses = str(number_crosses)
print("Cross(es): ", string_number_crosses)
# -----> * 1 versus 1 Function * <-----
elif choice == "1v1":
good_bad_input_v1 = input(v1_input)
if good_bad_input_v1 == "w":
first_number_v1_w = v1_list_w[0]
v1_list_w.remove(first_number_v1_w)
number_v1_w = v1_list_w[0]
string_number_v1_w = str(number_v1_w)
print("Won 1vs1: ", string_number_v1_w)
elif good_bad_input_v1 == "l":
first_number_v1_l = v1_list_l[0]
v1_list_l.remove(first_number_v1_l)
number_v1_l = v1_list_l[0]
string_number_v1_l = str(number_v1_l)
print("Lost 1vs1: ", string_number_v1_l)
else:
pass
first_number_v1 = v1_list[0]
v1_list.remove(first_number_v1)
number_v1 = v1_list[0]
string_number_v1 = str(number_v1)
print("1vs1: ", string_number_v1)
# -----> * Shots Function * <-----
elif choice == "shot":
good_bad_input_shots = input(shots_input)
if good_bad_input_shots == "on target":
first_number_shots_gd = shots_list_gd[0]
shots_list_gd.remove(first_number_shots_gd)
number_shots_gd = shots_list_gd[0]
string_number_shots_gd = str(number_shots_gd)
print("Shot(s) on target: ", string_number_shots_gd)
elif good_bad_input_shots == "off target":
first_number_shots_pd = shots_list_pd[0]
shots_list_pd.remove(first_number_shots_pd)
number_shots_pd = shots_list_pd[0]
string_number_shots_pd = str(number_shots_pd)
print("Shot(s) off target: ", string_number_shots_pd)
else:
pass
first_number_shots = shots_list[0]
shots_list.remove(first_number_shots)
number_shots = shots_list[0]
string_number_shots = str(number_shots)
print("Shot(s): ", string_number_shots)
# -----> * Headers Function * <-----
elif choice == "header":
good_bad_input_headers = input(headers_input)
if good_bad_input_headers == "on target":
first_number_headers_gd = headers_list_gd[0]
headers_list_gd.remove(first_number_headers_gd)
number_headers_gd = headers_list_gd[0]
string_number_headers_gd = str(number_headers_gd)
print("Header(s) on target: ", string_number_headers_gd)
elif good_bad_input_headers == "off target":
first_number_headers_pd = headers_list_pd[0]
headers_list_pd.remove(first_number_headers_pd)
number_headers_pd = headers_list_pd[0]
string_number_headers_pd = str(number_headers_pd)
print("Header(s) off target: ", string_number_headers_pd)
else:
pass
first_number_headers = headers_list[0]
headers_list.remove(first_number_headers)
number_headers = headers_list[0]
string_number_headers = str(number_headers)
print("Header(s): ", string_number_headers)
# -----> * Long Passes * <-----
elif choice == "long pass":
good_bad_input_long_passes = input(long_passes_input)
first_number_long_passes = long_passes_list[0]
long_passes_list.remove(first_number_long_passes)
number_long_passes = long_passes_list[0]
string_number_long_passes = str(number_long_passes)
print("Long Pass(es): ", string_number_long_passes)
if good_bad_input_long_passes == "first touch":
first_number_long_passes_first_touch = long_passes_list_first_touch[0]
long_passes_list_first_touch.remove(first_number_long_passes_first_touch)
number_long_passes_first_touch = long_passes_list_first_touch[0]
string_number_long_passes_first_touch = str(number_long_passes_first_touch)
print("Long Pass(es) first touch: ", string_number_long_passes_first_touch)
elif good_bad_input_long_passes == "second touch":
first_number_long_passes_second_touch = long_passes_list_second_touch[0]
long_passes_list_second_touch.remove(first_number_long_passes_second_touch)
number_long_passes_second_touch = long_passes_list_second_touch[0]
string_number_long_passes_second_touch = str(number_long_passes_second_touch)
print("Long Pass(es) second touch: ", string_number_long_passes_second_touch)
else:
pass
# -----> * Saves * <-----
elif choice == "save":
first_number_save = saves_list[0]
saves_list.remove(first_number_save)
number_save = saves_list[0]
string_number_save = str(number_save)
print("Save(s)", string_number_save)
elif choice == "q":
print("Are you sure that you want to finish the stat counting? (yes/no)")
quit_choice = input()
if quit_choice == "yes":
# -----> * Penalty_Kicks_goal_Quit_Function * <-----
if integer_pk_number_goal >= 1:
print("Penalty Kick goal(s): ", string_number_pk_goal)
elif integer_pk_number_goal == 0:
print("Penalty Kick goal(s): 0")
# -----> * Penalty_Kicks_saved_Quit_Function * <-----
if integer_pk_number_saved >= 1:
print("Saved Penalty Kick(s): ", string_number_pk_saved)
elif integer_pk_number_saved == 0:
print("Saved Penalty Kick(s): 0")
# -----> * Penalty_Kicks_missed_Quit_Function * <-----
if integer_pk_number_missed >= 1:
print("Missed Penalty Kick(s): ", string_number_pk_missed)
elif integer_pk_number_missed == 0:
print("Missed Penalty Kick(s): 0")
# -----> * Penalty_Kicks_Quit_Function * <-----
if integer_pk_number >= 1:
print("Penalty Kick(s): ", string_number_pk)
elif integer_pk_number == 0:
print("Penalty Kick(s): 0")
else:
pass
# -----> * Free_Kicks_gd_Quit_Function * <-----
if integer_fk_number_gd >= 1:
print("Free Kick(s) with Good delivery: ", string_number_fk_gd)
elif integer_fk_number_gd == 0:
print("Free Kick(s) with Good delivery: 0")
# -----> * Free_Kicks_Quit_Function * <-----
if integer_fk_number_pd >= 1:
print("Free Kick(s) with Poor delivery: ", string_number_fk_pd)
elif integer_fk_number_pd == 0:
print("Free Kick(s) with Poor delivery: 0")
# -----> * Free_Kicks_Quit_Function * <-----
if integer_fk_number >= 1:
print("Free Kick(s): ", string_number_fk)
elif integer_fk_number == 0:
print("Free Kick(s): 0")
break
elif quit_choice == "no":
pass
else:
pass
body()
に行くために、私は最小限に行ったように、それは仕事をdoesntのと、それはの無駄になりますように、すべての統計で終了した機能を追加しましたhaventは時間。また、他のバグも見つかるかもしれません。
[mcve]も追加してください。 – Julien
注: 'else:pass'は*常に完全に役に立たない*です。彼らは何もせず、あなたはそれらを単に取り除くことができます。実際には、あなたのコードに 'pass 'があるたびに何らかの方法で削除することができます。 – Bakuriu
ありがとう、私はそれらを削除します – mangafas