書籍『退屈なことはPythonにやらせよう』p49中で、以下のコードがあります。
Paython
1name = "" 2while not name: 3 print("名前を") 4 name = input() 5print("how many?") 6num_of_guests = int(input()) 7if num_of_guests: 8 print("Please check") 9print("got")
これって、なんで、if num_of_guests:が、if_num_guests!=0: と同じ意味なのでしょうか。num_of_guests = int(input(0))と0や""をいれなくていいのでしょうか。よくわかりません。わかりやすく説明していただけるとうれしいです。上はname=""となっているので理解できるのですが。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/03/04 04:59