I am trying to print 'okay, thanks'. When I run it on shell, it prints on separate line and the 'thanks' is printing before 'okay'. Can anyone help what I am doing wrong?
>>> test1 = Two()
>>> test1.b('abcd')
>>> thanks
>>> okay
My code
class One:
def a(self):
print('thanks')
class Two:
def b(self, test):
test = One()
print('okay', end = test.a())
解决方案
I'd try something like this as it means you don't have to change class One. This reduces the amount of classes you have to change, which isolates the change and the scope for error; and maintains the behaviour of class One
class One:
def a(self):
print('thanks')
class Two:
def b(self, test):
test = One()
print('okay', end=' ')
test.a()