Skip to main content
 首页 » 编程设计

python之一辆车,两辆车,红车,蓝车在 Grok

2024年12月31日8lovecherry

<分区>

我的设计课需要这方面的帮助..

这就是问题..

当您等待过马路时,您正在观察从您身边驶过的汽车,想看看红色还是蓝色更适合汽车。编写一个程序,读取每辆驶过的汽车的颜色字符串,然后打印出红色汽车的数量和蓝色汽车的数量。

输出必须是这样的

Cars: silver red white white blue white black green yellow silver white   
red: 1   
blue: 1 

这是我到目前为止所做的。

line = input ("Cars: ") 
words = 'red blue'.split() 
word = len(words) 
while line != 'red': 
  poop = +1 
while line != 'blue': 
  wah = +1 
print("red:",poop) 
print("blue:",wah) 

有人可以帮帮我吗?