[BangPypers] Fwd: Please help with this code

ankur gupta ankurimt01 at gmail.com
Sun Aug 19 05:40:57 EDT 2018


---------- Forwarded message ---------
From: ankur gupta <ankurimt01 at gmail.com>
Date: Sun, Aug 19, 2018 at 3:07 PM
Subject: Please help with this code
To: <bangpypers at python.org>


Dear Sir
I am new to  python programing, I am getting error while executing this
code. I want to generate multiple instance using while loop to store data
following is the code

class STUDENT:
no_of_students=0
def __init__(self,roll,name,present,absent):
self.roll=roll
self.name=name
self.present=present
self.absent=absent
STUDENT.no_of_students+=1

n='Y'
i=0
while n=='Y' or n=='y':
roll=input("ENTER NAME: ")
name=input("ENTER ROLL NO:")
present=input("ENTER NO. OF DAYS PRESENT:")
absent=input("ENTER NO. OF DAYS ABSENT:")
std[i] = STUDENT(roll,name,present,absent)
n=input("ENTER MORE RECORDS (Y/y)?...")
i+1


GETTING THIS ERROR

ankur at ankur-Lenovo-G50-80:~/PycharmProjects$ cd /home/ankur/PycharmProjects
; env "PYTHONIOENCODING=UTF-8" "PYTHO
NUNBUFFERED=1" /home/ankur/anaconda3/bin/python
/home/ankur/.vscode/extensions/ms-python.python-2018.4.0/pythonFi
les/PythonTools/visualstudio_py_launcher.py /home/ankur/PycharmProjects
42323 34806ad9-833a-4524-8cd6-18ca4aa74f1
4 RedirectOutput,RedirectOutput "/home/ankur/PycharmProjects/STUDENTS
ATTENDANCE.PY"
ENTER NAME: ANKUR
ENTER ROLL NO:1
ENTER NO. OF DAYS PRESENT:12
ENTER NO. OF DAYS ABSENT:8
Traceback (most recent call last):
  File "/home/ankur/PycharmProjects/STUDENTS ATTENDANCE.PY", line 17, in
<module>
    std[i] = STUDENT(roll,name,present,absent)
NameError: name 'std' is not defined


THANKS  IN ADVANCE
ANKUR GUPTA


More information about the BangPypers mailing list