'Problem Changing variable in a list of object list in python
I have an issue that I can't change the variables in the list in an object
when I try, the program is setting all the variables every object in the list
Is there any way to figure out?
(The number doesn't change but list is changing every pass in loop)
import openpyxl
class Student:
number = 3333
variables = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]
students = []
for i in range(2):
students.append(Student())
book = openpyxl.load_workbook('list.xlsx')
sheet = book.active
for i in range(2):
students[i].number = sheet.cell(i+1, 1).value
for j in range(10):
students[i].variables[j] = sheet.cell(i+1, j+2).value
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
