當我執行下面的代碼時,我只是得到一個空白屏幕,沒有任何輸出,如何糾正?#Program to find the length of the BMW using the len() function in Python!cars = ['bmw']len(cars)
4 回答

斯蒂芬大帝
TA貢獻1827條經驗 獲得超8個贊
如果您想str通過執行腳本來打印 Python 中的長度:
s = 'BMW'
print(len(s))
如果要car通過執行腳本來打印列表的長度:
print(len(cars))
如果您將這些直接提供給您的 Python 解釋器,這也將起作用:
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> cars = ['BMW']
>>> len(cars)
1
>>>
添加回答
舉報
0/150
提交
取消