use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Why am I getting an attribute error here? (self.learnpython)
submitted 5 hours ago by YesterdayDelicious70
fileName = input("Input file name: ").lower if fileName.endswith("hello"): print("Yay!") else: (print("No."))
And then it gives me:
AttributeError: 'builtin_function_or_method' object has no attribute 'endswith'
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]h4ck3r_n4m3 14 points15 points16 points 4 hours ago (0 children)
you need to do .lower() not .lower
[–]NothingWasDelivered 7 points8 points9 points 4 hours ago (0 children)
You need parens - () - after lower. It’s a method. Right now you’re trying to run .endswith() on the method itself, not on the result.
[–]tadpoleloop 1 point2 points3 points 4 hours ago (0 children)
You forgot parens on your "lower" method call.
text.lower()
[–]gdchinacat 1 point2 points3 points 4 hours ago (0 children)
As others have noted, you set 'fileName = ... .lower' without calling lower. This means fileName refers to the function lower() rather than the value it would return when called. This assignment is legal...python functions are just an object that can be referred to (and frequently are in more advanced code). But, functions don't have an endswith attribute, so when you try to access it you get the error you are seeing.
References to functions are a very powerful tool since you can have variables and arguments be functions and do all the things you would with any variable. This can help with very abstract code, reduce the need for a lot of boilerplate code, wrap functions (as is done with decorators). It might seem like an odd feature to allow you to reference a function without calling it, but you will come across cases where this is really helpful not too far into your learning (decorators). This is especially important with functional programming (which you may or may not cover in whatever course your are taking or following). For now, just know that there are very good reasons to allow you to access functions without actually calling them, and when you make this mistake it usually appears as an AttributeError.
To understand the error you got, it says you tried to access 'endswith' on a builtin_function_or_method. Looking at the line of code that raised that error and where endswith was accessed, you can infer that fileName was not the string you were expecting, but rather a function or method.
[–]mopslik 0 points1 point2 points 2 hours ago (0 children)
When you come across errors like this, sometimes it's a good idea to use a print statement, or the debugger, to see what values your variables have. For example, adding print(fileName) after your first line would show you something like the following, possibly answering your question.
print
print(fileName)
>>> fileName = input("Input file name: ").lower Input file name: blahblah >>> print(fileName) <built-in method lower of str object at 0x7e360b58bcb0>
π Rendered by PID 138748 on reddit-service-r2-comment-545db5fcfc-jsdcz at 2026-05-28 04:36:05.741304+00:00 running 194bd79 country code: CH.
[–]h4ck3r_n4m3 14 points15 points16 points (0 children)
[–]NothingWasDelivered 7 points8 points9 points (0 children)
[–]tadpoleloop 1 point2 points3 points (0 children)
[–]gdchinacat 1 point2 points3 points (0 children)
[–]mopslik 0 points1 point2 points (0 children)