我有一個想法,是想讓用戶輸入一個句子,然后可以print出第二和第四個單詞。
聽另一位大佬說可以用split函式做,但是無奈我太菜了,做不出來。
感謝!!
uj5u.com熱心網友回復:
sentence = input("請輸入一句話")
words = sentence.split()
if len(words)>=4:
print(words[1])#第二個
print(words[3])#第四個
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/136230.html
上一篇:匯編題目求答
