前提・実現したいこと
参考書の中の一文で理解できないことがあったので、理解したい。
ソースコードの中の
fond_one = False
found_one = True
の動きがどうなっているのか。
下の一文のelseがない場合の文章の動き→ 該当のソースコード
python
1cheeses = [] 2for cheese in cheeses: 3 print('This shop has some lovely', cheese)#cheeses にあるものをcheeseで出力 4 break 5else: 6 print('This is not much of a cheese shop, is it?')
該当のソースコード
python
1cheeses = [] 2found_one = False 3for cheese in cheeses: 4 found_one = True 5 print('This shop has some lovely', cheese) 6 break 7 8if not found_one: 9 print('This is not much of a cheese shop, is it?')
出力結果
This is not much of a cheese shop, is it?
試したこと
1.False,True(cheeses=[]) if not 出力
2.False,True (cheeses=['big cheese']) for 出力
3.False,False (cheeses=[]) if not 出力
4.False,False (cheeses=['big cheese']) for, if not 出力
5.True,False(cheeses=[]) 出力なし
6.True,False(cheeses=['big cheese']) for, if not出力
7.True,True(cheeses=[]) 出力なし
8.True,True(cheeses=['big cheese']) for 出力
動きがわかるかなと思ったがダメでした。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/21 04:01
2019/05/21 04:01
2019/05/21 04:04
2019/05/21 04:05
2019/05/21 04:29