[英]How do I check if x has more or less than seven integers?
x = []
y = int(input("Hello, please enter your date of birth in this format: DDMMYYYY"))
x.append(y)
b = len.x()
if b > 7:
input("Please enter your date of birth correctly in the above format")
elif b < 7:
input("Please enter your date of birth correctly in the above format")
目前我收到此錯誤:
b = len.x()
AttributeError: 'builtin_function_or_method' 對象沒有屬性 'x'
抱歉,我對 python 還很陌生,謝謝大家的幫助!
如果您正在處理日期和時間,您可以查看以下線程中給出的解決方案。
Python'a len()
是一個函數。 它不像你想象的那樣工作。 你這樣做是不正確的。 取而代之的是:
b = len.x()
做這個:
b = len(str(x))
您似乎對len()
函數感到困惑。 我建議您閱讀有關它的Python 文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.