[英]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")
At the moment I'm getting this error:目前我收到此错误:
b = len.x()
b = len.x()
AttributeError: 'builtin_function_or_method' object has no attribute 'x'
AttributeError: 'builtin_function_or_method' 对象没有属性 'x'
Sorry, I'm quite new to python, thanks for all the help!抱歉,我对 python 还很陌生,谢谢大家的帮助!
You can checkout the solution given in the below thread if you are dealing with date and time.如果您正在处理日期和时间,您可以查看以下线程中给出的解决方案。
Getting input date from the user in python using datetime.datetime 在 python 中使用 datetime.datetime 从用户获取输入日期
Python'a len()
is a function . Python'a
len()
是一个函数。 It does not work like you think it does.它不像你想象的那样工作。 What you doing is incorrect.
你这样做是不正确的。 Instead of this:
取而代之的是:
b = len.x()
Do this:做这个:
b = len(str(x))
You seem to be confused about the len()
function.您似乎对
len()
函数感到困惑。 I suggest you read the Python documentation about it.我建议您阅读有关它的Python 文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.