Class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Class

class a: def __init__(self): pass def c(self,d): d = print a = a() a.c(('Hello!')) why it prints nothing?

31st May 2017, 5:01 PM
Thomas Caio Dias
Thomas Caio Dias - avatar
2 Answers
+ 5
You should replace: d = print with: print(d) It will work then.
31st May 2017, 4:58 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
class a: def __init__(self): pass def c(self,d): print(d) x = a() x.c('Hello!') Also you should create an object with a different name of "a" because "a" is already the name of the class and so there might be conflicts between a the class and a the object.
31st May 2017, 5:02 PM
Glozi30
Glozi30 - avatar