|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Question about a list
I have made a list using the following code
Code:
list = [] for locn in range(10): i=0 list.append(i) This obviously makes a new list with 10 values of integer 0 in it. What I am trying to do now is replace those values with 10 values of integer 99 instead. I tried the code below but that just seems to add them on the end instead. Code:
for locn in range(10): i=99 list1.append(i) How do I overwrite these values??? Cheers |
|
#2
|
|||
|
|||
|
Code:
list1[locn] = i Dave |
|
#3
|
|||
|
|||
|
Quote:
You could also just say: or replace “0” with anything you want to repeat in the list. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Question about a list |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|