Creating class constructors | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Creating class constructors

I canā€™t quite get this, has anyone got a clue? Fill in the blanks to create a class and itā€™s constructor, taking one name and assigning it to the name ā€œattributeā€. Then create an object of the class. Class student: Def __init__(self, name): Self ***** = name Test = Student (ā€œBobā€) The *ā€™s represent the unanswered part! Can anyone help?

19th Feb 2019, 11:48 AM
Brent Malcolm
17 Respostas
0
self.attribute = name
19th Feb 2019, 12:24 PM
HonFu
HonFu - avatar
0
nope it doesnt fit!
19th Feb 2019, 1:12 PM
Brent Malcolm
0
it only has 5 characters!
19th Feb 2019, 1:13 PM
Brent Malcolm
0
The solution is likely '.name'. But that's not what your question suggests.
19th Feb 2019, 2:16 PM
HonFu
HonFu - avatar
0
nope its not name either!
19th Feb 2019, 6:57 PM
Brent Malcolm
0
Sure you copied the riddle correctly? Where's it even from?
19th Feb 2019, 7:09 PM
HonFu
HonFu - avatar
0
im positive! triple checked!
19th Feb 2019, 7:10 PM
Brent Malcolm
0
Because the syntax is all over the place. ;-p
19th Feb 2019, 7:11 PM
HonFu
HonFu - avatar
0
nope checked!
19th Feb 2019, 7:11 PM
Brent Malcolm
0
I just looked it up in the Tutorial since you just wouldn't tell me. .name it is, just as I said.
19th Feb 2019, 7:14 PM
HonFu
HonFu - avatar
0
no it is not, i just told you, that was the second answer i used, well before posting to this forum, and it has five characters! sorry!
19th Feb 2019, 7:16 PM
Brent Malcolm
0
Also in the riddle description it says: 'name' attribute, not name 'attribute'. And look at your code: Indentation has totally disappeared, def and class starting with capitals... Let me tell you one thing now: Sloppy doesn't work with code. You got to pay more attention to the details!
19th Feb 2019, 7:17 PM
HonFu
HonFu - avatar
0
.name! Open your eyes for god's sake, there's a point!!!
19th Feb 2019, 7:17 PM
HonFu
HonFu - avatar
0
ive put the point in, dont worry about it ill see someone in a couple of hours!
19th Feb 2019, 7:18 PM
Brent Malcolm
0
That 'someone' can only tell you what I just told you a few times. Does your smartphone autocorrect a space in there after the point? (Mine does it.) You'd of course have to erase that.
19th Feb 2019, 7:22 PM
HonFu
HonFu - avatar
0
man i told you, ive tried it mant times, I will see someone about it! thanks!
19th Feb 2019, 7:55 PM
Brent Malcolm
0
What does HonFu stand for? HongKong Kung Fu?? lol! with the picture of a tekken character it fits, Do you do Wing Chun??
24th Feb 2019, 12:06 AM
Brent Malcolm