+ 1

Some help to finish this code in notebook, please

https://code.sololearn.com/cRW56iI21SGe '''Create a class called Person. This class will contain as its attributes: name, ID, address, phone number. By method we will only take into consideration that it will print the person's data on the screen. Use this Person class to create a list of persons and display each of them. The data of each person must be in a file called personas.txt. The format of this file is one line with the data for each person. They are separated by ';'. It contains information in this order: nombre; DNI; direcciĂłn; pepe;2345; calle uno, 899023 sara;2346; calle dos, 167890 juan;4567; calle tres, 906089 '''

2nd May 2022, 3:09 PM
Rayane Oliveira
Rayane Oliveira - avatar
5 Answers
+ 2
Next all you need is : creates data for persons by objects like persena(pepe;2345; calle uno, 899023) and add these to a file by creating a new file. as like lineas = open('c:\ejemplo\personas.txt', 'w') write objects into file. next then open same file in read mode and readlines into a list then display data.. as lineas = open('c:\ejemplo\personas.txt', 'r').readlines() display by a loop.
2nd May 2022, 5:31 PM
Jayakrishna 🇼🇳
2nd May 2022, 5:13 PM
JaScript
JaScript - avatar
+ 5
You have No closing quote for file open Use lineas = open('c:\ejemplo\personas.txt'). readlines() And your class name is persona as you defined but using Persona (capital P) Hope it helps..
2nd May 2022, 3:44 PM
Jayakrishna 🇼🇳
+ 4
https://code.sololearn.com/c7qKpO18WaCJ/?ref=app you have to return a string in the string dunder. then youre able to just call print on a Persona object. You also need to capitalize the 'p' in the class decleration
2nd May 2022, 3:48 PM
Slick
Slick - avatar
- 1
I change a lit bit, what do you mean as “capitalize” Slick your code is so diferent than man that it’s difficult for me understain
2nd May 2022, 5:05 PM
Rayane Oliveira
Rayane Oliveira - avatar