+ 1

Can there be a situation we can write a class and a function within it then call the function

python class

28th May 2018, 5:56 AM
Omoriwhovo Jude OgheneKome
Omoriwhovo Jude OgheneKome - avatar
7 Respuestas
+ 5
class test: def test_func(): print('test') test.test_func() # or class test: def test_func(self): print('test') obj = test() obj.test_func()
28th May 2018, 6:16 AM
Hatsy Rei
Hatsy Rei - avatar
+ 5
have a look at @Neet s prog. even if it has little prob, it shows well. simply put fun into a class. not too complicated
28th May 2018, 6:16 AM
Oma Falk
Oma Falk - avatar
+ 4
yes... you describe recursion
28th May 2018, 6:08 AM
Oma Falk
Oma Falk - avatar
+ 2
it means we can define variables in that function then call it at the console to perform back operation.right?
28th May 2018, 6:19 AM
Omoriwhovo Jude OgheneKome
Omoriwhovo Jude OgheneKome - avatar
+ 2
Maybe the answer ist in this code? https://code.sololearn.com/cpD1FbHOaqS8/?ref=app
28th May 2018, 7:20 AM
Sebastian Keßler
Sebastian Keßler - avatar
+ 1
can you plz write a simple code to back up your answer
28th May 2018, 6:10 AM
Omoriwhovo Jude OgheneKome
Omoriwhovo Jude OgheneKome - avatar