質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

解決済

1回答

1443閲覧

python エラー

reotantan

総合スコア295

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2016/01/31 14:08

difference=((Cmpnum-Playernum)%5)がエラーになってしまいます、ご指摘よろしくお願いします。

コード # Rock-paper-scissors-lizard-Spock template # The key idea of this program is to equate the strings # "rock", "paper", "scissors", "lizard", "Spock" to numbers # as follows: # # 0 - rock # 1 - Spock # 2 - paper # 3 - lizard # 4 - scissors # helper functions import random def name_to_number(name): if name==rock: return 0 elif name==Spock: return 1 elif name==paper: return 2 elif name==lizard: return 3 elif name==scissors: return 4 else: print("its not appropriate name") # delete the following pass statement and fill in your code below # convert name to number using if/elif/else # don't forget to return the result! def number_to_name(number): # delete the following pass statement and fill in your code below if number==0: return rock if number==1: return Spock if number==2: return lizard if number==3: return scissors else: print("its not appropriate number") # convert number to a name using if/elif/else # don't forget to return the result! def rpsls(player_choice): # delete the following pass statement and fill in your code below # print a blank line to separate consecutive games print("________________________________") # print out the message for the player's choice print("player_choice") # convert the player's choice to player_number using the function name_to_number() Playernum=name_to_number(player_choise) # compute random guess for comp_number using random.randrange() Cmpnum=random.randrange(0,4) # convert comp_number to comp_choice using the function number_to_name() CmpChoice=number_to_name(rn) # print out the message for computer's choice print("Computer's choise is{0}".format(CmpChoise) # compute difference of comp_number and player_number modulo five difference=((Cmpnum-Playernum)%5) # use if/elif/else to determine winner, print winner message # test your code - THESE CALLS MUST BE PRESENT IN YOUR SUBMITTED CODE rpsls("rock") rpsls("Spock") rpsls("paper") rpsls("lizard") rpsls("scissors") # always remember to check your completed program against the grading rubric

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

python

1print("Computer's choise is{0}".format(CmpChoise)

のカッコが閉じられてません。

正しくは

python

1print("Computer's choise is{0}".format(CmpChoise))

です。

投稿2016/02/02 06:33

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

reotantan

2016/02/02 06:40

解説ありがとうございました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問