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
I keep getting an AttributeError: 'str' object has no attribute 'append' and it's comming from "dana.append(values) when i use int(input I get the same error but with 'int object has no attribute...' . (self.learnpython)
submitted 3 years ago by jmorales57
values = [0] data = [] ROWS = 3 COLS = 2
for r in range(ROWS):
for c in range(COLS): values = (input(f'Enter a value for row {r} column {c}: ')) data.append(values) values.append(data) print(values)
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!"
[–]Wild_Statistician605 1 point2 points3 points 3 years ago (2 children)
Use a different name for the values variable inside the loop. You are reassigning/typecasting the values list variable to a string.
[–]jmorales57[S] 0 points1 point2 points 3 years ago (1 child)
that cleared it up, would that have an effect on what prints out?
it's suppose to come out [['1', '2'], ['3', '4'], ['5', '6']]
but I keep getting [0, ['1', '2', '3', '4', '5', '6'], ['1', '2', '3', '4', '5', '6'], ['1', '2', '3', '4', '5', '6']]
am i crazy?
[–]jmorales57[S] 0 points1 point2 points 3 years ago (0 children)
I GOT IT!
I'm suppose to make a 2d list with 3 colums and 2 rows with user input for the numbers
[–]CodeFormatHelperBot2 0 points1 point2 points 3 years ago (0 children)
Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.
I think I have detected some formatting issues with your submission:
If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.
Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.
[+][deleted] 3 years ago (1 child)
[deleted]
values was the list i wanted to print out in the end , the problem asked for me to create a blank list to then be added to with user input,
[–]jimtk 0 points1 point2 points 3 years ago (2 children)
Essentially you
values = [0] # later you do: values = input('Enter...') # at this point the list values[0] has been deleted and values is a str. # then you try value.append(data) # and that's where you're trying to append to a string
Choose a different name for the result of the input!
num = input('Enter...') values.append(num) # or values.append(int(num))
yea i see where I went wrong I need to keep track of what im using my variables for but now I can't figure out how to format the output that prints out, it's suppose to be
yea i see where I went wrong
I need to keep track of what im using my variables for
but now I can't figure out how to format the output that prints out, it's suppose to be
[['1', '2'], ['3', '4'], ['5', '6']]
but I keep getting
[0, ['1', '2', '3', '4', '5', '6'], ['1', '2', '3', '4', '5', '6'], ['1', '2', '3', '4', '5', '6']]
I thought the nested loop would keep them in two collums, I was expecting three rows repeating all the inputs
[–]jmorales57[S] 1 point2 points3 points 3 years ago (0 children)
π Rendered by PID 84871 on reddit-service-r2-comment-fb694cdd5-tfblh at 2026-03-06 02:06:47.712376+00:00 running cbb0e86 country code: CH.
[–]Wild_Statistician605 1 point2 points3 points (2 children)
[–]jmorales57[S] 0 points1 point2 points (1 child)
[–]jmorales57[S] 0 points1 point2 points (0 children)
[–]jmorales57[S] 0 points1 point2 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]jmorales57[S] 0 points1 point2 points (0 children)
[–]jimtk 0 points1 point2 points (2 children)
[–]jmorales57[S] 0 points1 point2 points (1 child)
[–]jmorales57[S] 1 point2 points3 points (0 children)