So I want to print a string and then call a method, which is inside the class within the same line.
My code is following:
class A:
def a(self):
return 'bla bla\n' + A.b(self)
def b(self):
self.input = input('Type here:')
if self.input == 'yes':
return '\nok'
else:
return '\nnot ok'
d = A()
print(d.a())
The results I get:
Type here: (when I type 'Yes')
bla bla
ok
What I want is this:
bla bla
Type here: (when I type 'Yes')
ok
I want that 'bla bla' would be displayed first and then based on the input you would get either 'ok' or 'not ok'.
Can someone please help with what do I need to change?
bneeds to be called beforeacan return, which means theinputstring will be printed first. I'd move the input-asking code out, pass the result intob, and havebmake decisions based on already-received input.