teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

タイトルの修正

2021/09/22 01:45

投稿

Stella_Aqr
Stella_Aqr

スコア0

title CHANGED
@@ -1,1 +1,1 @@
1
- 同じ文字列を参照しているのに同じ文字列だと判定されないので、同じ文字列だと判定できるようにしたい
1
+ 同じ文字列を比較しているのに同じ文字列だと判定されないので、同じ文字列だと判定できるようにしたい
body CHANGED
File without changes

2

str.pyのif str(correct_words[q_nums[q_nums_index]]) is str(ans_words[q_nums_index]): の is を == に変更

2021/09/22 01:44

投稿

Stella_Aqr
Stella_Aqr

スコア0

title CHANGED
File without changes
body CHANGED
@@ -38,7 +38,7 @@
38
38
  q_nums=[0,3,4]
39
39
  q_nums_index=0
40
40
 
41
- if str(correct_words[q_nums[q_nums_index]]) is str(ans_words[q_nums_index]):
41
+ if str(correct_words[q_nums[q_nums_index]]) == str(ans_words[q_nums_index]):
42
42
  print("回答:"+str(correct_words[q_nums[q_nums_index]]))
43
43
  print("入力した答え:"+str(ans_words[q_nums_index]))
44
44
  print("\n"+str(q_nums_index+1)+":正解")

1

I have an apple. のピリオドを無くしました。

2021/09/21 15:22

投稿

Stella_Aqr
Stella_Aqr

スコア0

title CHANGED
File without changes
body CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  ###~配列について~
9
9
  正解となる文字列は単語ごとにリストとして、correct_wordsに格納されています。
10
- ["I have an apple."]から
10
+ ["I have an apple"]から
11
11
  ["I","have","an","apple"]
12
12
  という感じになっています。
13
13