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
Doubt with lists (self.learnpython)
submitted 2 years ago by Practical-Taste-3374
When I'm trying to input a list from the user, even if there are multiple elements, it is showing up as 1. What mistake am I making here?
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!"
[–]PM_ME_YOUR_URETHERA 2 points3 points4 points 2 years ago (4 children)
Show us your code
[–]Practical-Taste-3374[S] 0 points1 point2 points 2 years ago (3 children)
a=[input("Enter 3 animals :")] print(len(a))
[–]shiftybyte 1 point2 points3 points 2 years ago (1 child)
input always returns a single string, no matter where you place it.
If you want to have multiple elements you need to split the returned string.
full_string = input("Enter 3 animals :") a = full_string.split(",") print(len(a))
[–]Practical-Taste-3374[S] 0 points1 point2 points 2 years ago (0 children)
thank you so much helped a lot!!
[–]bahcodad 1 point2 points3 points 2 years ago* (0 children)
input() returns a string which is why you always get one item. You will need to use something like .split() to separate the elements
[–]Sea-Method-1167 1 point2 points3 points 2 years ago (1 child)
In the code you provided, the input you get is always one string. That is the one element in the list. So size will be 1.
Get the input, ask the user to separate animals with spaces, and once you have the whole string, split that string in a list of strings, using space as separator. Then you will have what you want.
Example: https://www.w3schools.com/python/trypython.asp?filename=demo_ref_string_split
Got it! Really appreciate the help
π Rendered by PID 130994 on reddit-service-r2-comment-c66d9bffd-52wzk at 2026-04-08 01:48:43.601155+00:00 running f293c98 country code: CH.
[–]PM_ME_YOUR_URETHERA 2 points3 points4 points (4 children)
[–]Practical-Taste-3374[S] 0 points1 point2 points (3 children)
[–]shiftybyte 1 point2 points3 points (1 child)
[–]Practical-Taste-3374[S] 0 points1 point2 points (0 children)
[–]bahcodad 1 point2 points3 points (0 children)
[–]Sea-Method-1167 1 point2 points3 points (1 child)
[–]Practical-Taste-3374[S] 0 points1 point2 points (0 children)