Timeline for Python adding an integer to a list
Current License: CC BY-SA 3.0
14 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 21, 2019 at 2:03 | history | bumped | Community Bot | This question has answers that may be good or bad; the system has marked it active so that they can be reviewed. | |
| Mar 21, 2019 at 8:04 | history | bumped | Community Bot | This question has answers that may be good or bad; the system has marked it active so that they can be reviewed. | |
| Apr 17, 2017 at 12:42 | answer | added | Mani | timeline score: 2 | |
| Apr 17, 2017 at 12:42 | answer | added | Ali Ezzat Odeh | timeline score: 0 | |
| Apr 17, 2017 at 12:37 | answer | added | James Scholes | timeline score: 0 | |
| Apr 17, 2017 at 12:35 | answer | added | mahendra kamble | timeline score: 0 | |
| Apr 17, 2017 at 12:34 | comment | added | Oliver Dungey | Thanks for the solutions, adding the equals to the final before last line worked :) | |
| Apr 17, 2017 at 12:32 | history | edited | jonrsharpe | CC BY-SA 3.0 |
deleted 6 characters in body
|
| Apr 17, 2017 at 12:30 | comment | added | roganjosh |
case_numbers.append(int(case_number)) is the standard way. The reason your approach doesn't change the list is that you don't assign the modified list back to case_numbers e.g. case_numbers = case_numbers + [int(case_number)]
|
|
| Apr 17, 2017 at 12:30 | comment | added | Martijn Pieters |
or use case_numbers.append(...).
|
|
| Apr 17, 2017 at 12:30 | comment | added | Serenity |
You have a misprint, write case_numbers+=[int(case_number)] (forgot the equal)
|
|
| Apr 17, 2017 at 12:30 | comment | added | Tom de Geus |
You need to replace the final before last line with case_numbers+=[int(case_number)]
|
|
| Apr 17, 2017 at 12:30 | comment | added | Moses Koledoye |
+ creates a new list which you're discarding. What you want is case_numbers.append(int(case_number))
|
|
| Apr 17, 2017 at 12:28 | history | asked | Oliver Dungey | CC BY-SA 3.0 |