第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在“為什么”循環(huán)中添加“if”命令

如何在“為什么”循環(huán)中添加“if”命令

開心每一天1111 2021-07-30 13:00:39
所以我有一些代碼,像這樣:while loopCode == 1:userCommand = raw_input('Type a command (type \'help\' for syntax): ')if userCommand == help:    print 'flight: this command will be used to list a flight'    print 'restaurant: you will be prompted to type the name of the restaurant, and how much you will spend there'如您所見,循環(huán)中有一個if條件while。但是當我被提示輸入文本時,我應該輸入“幫助”以激活條件。但是當我這樣做時,while循環(huán)會忽略條件。這是為什么?
查看完整描述

1 回答

?
呼啦一陣風

TA貢獻1802條經(jīng)驗 獲得超6個贊

這是因為 if 語句沒有正確縮進,并且它的條件沒有指定為字符串 'help':


while  1:

    userCommand = input('Type a command (type \'help\' for syntax): ')

    if userCommand == 'help':

        print ('flight: this command will be used to list a flight')

        break


查看完整回答
反對 回復 2021-08-03
  • 1 回答
  • 0 關注
  • 137 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號