Python printing thrice while I called the function twice, why is this so?
I am new in python and I was trying to understand how does self work. As I came from JavaScript I think its bit similar to this. If I am wrong please correct me. In the meantime I wrote this code:
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
print("branch opened")
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
print(x.open_branch())
and got the output:
None
branch opened
None
As I called the open_branch() twice. It should not print thrice. I think it should print,
branch opened // for first call
None // for 2nd call
you could paste the code here and see
Please somebody explain this.
python
|
show 4 more comments
I am new in python and I was trying to understand how does self work. As I came from JavaScript I think its bit similar to this. If I am wrong please correct me. In the meantime I wrote this code:
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
print("branch opened")
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
print(x.open_branch())
and got the output:
None
branch opened
None
As I called the open_branch() twice. It should not print thrice. I think it should print,
branch opened // for first call
None // for 2nd call
you could paste the code here and see
Please somebody explain this.
python
3
Youre printing the return value of the function which is none
– Antti Haapala
Nov 15 '18 at 10:24
2
You're calling print thrice
– Antti Haapala
Nov 15 '18 at 10:24
Worth noting this would print 3 times in JS as well.
– kabanus
Nov 15 '18 at 10:24
i really dont get it. where am i calling thrice ? i just wrote print print(y.open_branch()) && print(x.open_branch())
– Sanjida lina
Nov 15 '18 at 10:28
1
print("branch opened")
—print(y.open_branch())
—print(x.open_branch())
— That's three.
– khelwood
Nov 15 '18 at 10:30
|
show 4 more comments
I am new in python and I was trying to understand how does self work. As I came from JavaScript I think its bit similar to this. If I am wrong please correct me. In the meantime I wrote this code:
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
print("branch opened")
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
print(x.open_branch())
and got the output:
None
branch opened
None
As I called the open_branch() twice. It should not print thrice. I think it should print,
branch opened // for first call
None // for 2nd call
you could paste the code here and see
Please somebody explain this.
python
I am new in python and I was trying to understand how does self work. As I came from JavaScript I think its bit similar to this. If I am wrong please correct me. In the meantime I wrote this code:
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
print("branch opened")
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
print(x.open_branch())
and got the output:
None
branch opened
None
As I called the open_branch() twice. It should not print thrice. I think it should print,
branch opened // for first call
None // for 2nd call
you could paste the code here and see
Please somebody explain this.
python
python
edited Nov 15 '18 at 10:31
Sanjida lina
asked Nov 15 '18 at 10:21
Sanjida linaSanjida lina
488
488
3
Youre printing the return value of the function which is none
– Antti Haapala
Nov 15 '18 at 10:24
2
You're calling print thrice
– Antti Haapala
Nov 15 '18 at 10:24
Worth noting this would print 3 times in JS as well.
– kabanus
Nov 15 '18 at 10:24
i really dont get it. where am i calling thrice ? i just wrote print print(y.open_branch()) && print(x.open_branch())
– Sanjida lina
Nov 15 '18 at 10:28
1
print("branch opened")
—print(y.open_branch())
—print(x.open_branch())
— That's three.
– khelwood
Nov 15 '18 at 10:30
|
show 4 more comments
3
Youre printing the return value of the function which is none
– Antti Haapala
Nov 15 '18 at 10:24
2
You're calling print thrice
– Antti Haapala
Nov 15 '18 at 10:24
Worth noting this would print 3 times in JS as well.
– kabanus
Nov 15 '18 at 10:24
i really dont get it. where am i calling thrice ? i just wrote print print(y.open_branch()) && print(x.open_branch())
– Sanjida lina
Nov 15 '18 at 10:28
1
print("branch opened")
—print(y.open_branch())
—print(x.open_branch())
— That's three.
– khelwood
Nov 15 '18 at 10:30
3
3
Youre printing the return value of the function which is none
– Antti Haapala
Nov 15 '18 at 10:24
Youre printing the return value of the function which is none
– Antti Haapala
Nov 15 '18 at 10:24
2
2
You're calling print thrice
– Antti Haapala
Nov 15 '18 at 10:24
You're calling print thrice
– Antti Haapala
Nov 15 '18 at 10:24
Worth noting this would print 3 times in JS as well.
– kabanus
Nov 15 '18 at 10:24
Worth noting this would print 3 times in JS as well.
– kabanus
Nov 15 '18 at 10:24
i really dont get it. where am i calling thrice ? i just wrote print print(y.open_branch()) && print(x.open_branch())
– Sanjida lina
Nov 15 '18 at 10:28
i really dont get it. where am i calling thrice ? i just wrote print print(y.open_branch()) && print(x.open_branch())
– Sanjida lina
Nov 15 '18 at 10:28
1
1
print("branch opened")
— print(y.open_branch())
— print(x.open_branch())
— That's three.– khelwood
Nov 15 '18 at 10:30
print("branch opened")
— print(y.open_branch())
— print(x.open_branch())
— That's three.– khelwood
Nov 15 '18 at 10:30
|
show 4 more comments
4 Answers
4
active
oldest
votes
Ok, you have the following code:
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
print("branch opened")
x = Restaurant()
y = Restaurant()
till here you have two objects of type 'Restaurant'.
y.bankrupt = True
Here you changed the attribute bankrupt
of the object stored in the variable y
print(y.open_branch())
This will output
None
only; why? Well first of all you are calling the function y.open_branch()
but this function will not output anything because the attribute bankrupt
is true so if not self.bankrupt
is evaluated to false and thus the print statement is not executed. However the function open_branch()
is also not returning anything (there is no return true
statement or so. So print(y.open_branch())
is equal to print(None)
which will output None
. Next
print(x.open_branch())
For x the attribut bankrupt
is false, so if not self.bankrupt
is true and the print statement print("branch opened")
will get evaluated. Afterwards None
will be outputted for the same reason as why None
got outputted by print(y.open_branch())
.
1
i got it now. actually this if not made me puzzled. thanks a lot
– Sanjida lina
Nov 15 '18 at 10:42
add a comment |
The two print statements at the end are only printing the returned results of the method:
print(y.open_branch())
print(x.open_branch())
Since python returns None
by default if you don't explicitly specify a return statement, and you are calling the methods twice, then it's expected that you see two None
statements.
If you call the method without print, you will see a single printed message.
y.open_branch()
x.open_branch()
You could improve your code by adding return statements within the method and doing the print outside, as you are doing right now. Something like
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
return "branch opened"
return "branch closed"
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
# output:'branch closed'
print(x.open_branch())
# output: 'branch opened'
add a comment |
What you're doing is you're calling print
on the return value of open_branch
.
So when you see it print None
, you're seeing the outcome of print(x.open_branch()
and print(y.open_branch()
.
When you see branch opened
, that's the result of the print inside open_branch
.
Try this:
class Restaurant(object):
bankrupt = False
def open_branch(self):
result = ""
if self.bankrupt:
result = "Restaurant is bankrupt"
else:
result = "Branch opened"
return result
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
print(x.open_branch())
add a comment |
There are a few things that are giving you issues here:
Your
open_branch
function isn't returning anything, so when you callprint(self.open_branch(x))
it's printingNone
, which is what all functions in Python return by default if there is noreturn
statement. You can solve this issue by replacingif not self.bankrupt:
print("branch opened")with
if not self.bankrupt:
return "branch opened"You're calling
print
three times, which is why you're getting three lines printed on the console (although this will resolve itself if you replace theprint
in the function with thereturn
statement I detailed above).You should put an
else
statement under yourif
clause, so that it will return something useful (instead ofNone
ifself.bankrupt == True
) and you can tell if the branch was opened or not. I'd suggest something like:if not self.bankrupt:
return "branch opened"
else:
return "Restaurant is bankrupt, branch could not be opened"
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53317230%2fpython-printing-thrice-while-i-called-the-function-twice-why-is-this-so%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Ok, you have the following code:
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
print("branch opened")
x = Restaurant()
y = Restaurant()
till here you have two objects of type 'Restaurant'.
y.bankrupt = True
Here you changed the attribute bankrupt
of the object stored in the variable y
print(y.open_branch())
This will output
None
only; why? Well first of all you are calling the function y.open_branch()
but this function will not output anything because the attribute bankrupt
is true so if not self.bankrupt
is evaluated to false and thus the print statement is not executed. However the function open_branch()
is also not returning anything (there is no return true
statement or so. So print(y.open_branch())
is equal to print(None)
which will output None
. Next
print(x.open_branch())
For x the attribut bankrupt
is false, so if not self.bankrupt
is true and the print statement print("branch opened")
will get evaluated. Afterwards None
will be outputted for the same reason as why None
got outputted by print(y.open_branch())
.
1
i got it now. actually this if not made me puzzled. thanks a lot
– Sanjida lina
Nov 15 '18 at 10:42
add a comment |
Ok, you have the following code:
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
print("branch opened")
x = Restaurant()
y = Restaurant()
till here you have two objects of type 'Restaurant'.
y.bankrupt = True
Here you changed the attribute bankrupt
of the object stored in the variable y
print(y.open_branch())
This will output
None
only; why? Well first of all you are calling the function y.open_branch()
but this function will not output anything because the attribute bankrupt
is true so if not self.bankrupt
is evaluated to false and thus the print statement is not executed. However the function open_branch()
is also not returning anything (there is no return true
statement or so. So print(y.open_branch())
is equal to print(None)
which will output None
. Next
print(x.open_branch())
For x the attribut bankrupt
is false, so if not self.bankrupt
is true and the print statement print("branch opened")
will get evaluated. Afterwards None
will be outputted for the same reason as why None
got outputted by print(y.open_branch())
.
1
i got it now. actually this if not made me puzzled. thanks a lot
– Sanjida lina
Nov 15 '18 at 10:42
add a comment |
Ok, you have the following code:
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
print("branch opened")
x = Restaurant()
y = Restaurant()
till here you have two objects of type 'Restaurant'.
y.bankrupt = True
Here you changed the attribute bankrupt
of the object stored in the variable y
print(y.open_branch())
This will output
None
only; why? Well first of all you are calling the function y.open_branch()
but this function will not output anything because the attribute bankrupt
is true so if not self.bankrupt
is evaluated to false and thus the print statement is not executed. However the function open_branch()
is also not returning anything (there is no return true
statement or so. So print(y.open_branch())
is equal to print(None)
which will output None
. Next
print(x.open_branch())
For x the attribut bankrupt
is false, so if not self.bankrupt
is true and the print statement print("branch opened")
will get evaluated. Afterwards None
will be outputted for the same reason as why None
got outputted by print(y.open_branch())
.
Ok, you have the following code:
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
print("branch opened")
x = Restaurant()
y = Restaurant()
till here you have two objects of type 'Restaurant'.
y.bankrupt = True
Here you changed the attribute bankrupt
of the object stored in the variable y
print(y.open_branch())
This will output
None
only; why? Well first of all you are calling the function y.open_branch()
but this function will not output anything because the attribute bankrupt
is true so if not self.bankrupt
is evaluated to false and thus the print statement is not executed. However the function open_branch()
is also not returning anything (there is no return true
statement or so. So print(y.open_branch())
is equal to print(None)
which will output None
. Next
print(x.open_branch())
For x the attribut bankrupt
is false, so if not self.bankrupt
is true and the print statement print("branch opened")
will get evaluated. Afterwards None
will be outputted for the same reason as why None
got outputted by print(y.open_branch())
.
answered Nov 15 '18 at 10:39
quantquant
1,60711527
1,60711527
1
i got it now. actually this if not made me puzzled. thanks a lot
– Sanjida lina
Nov 15 '18 at 10:42
add a comment |
1
i got it now. actually this if not made me puzzled. thanks a lot
– Sanjida lina
Nov 15 '18 at 10:42
1
1
i got it now. actually this if not made me puzzled. thanks a lot
– Sanjida lina
Nov 15 '18 at 10:42
i got it now. actually this if not made me puzzled. thanks a lot
– Sanjida lina
Nov 15 '18 at 10:42
add a comment |
The two print statements at the end are only printing the returned results of the method:
print(y.open_branch())
print(x.open_branch())
Since python returns None
by default if you don't explicitly specify a return statement, and you are calling the methods twice, then it's expected that you see two None
statements.
If you call the method without print, you will see a single printed message.
y.open_branch()
x.open_branch()
You could improve your code by adding return statements within the method and doing the print outside, as you are doing right now. Something like
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
return "branch opened"
return "branch closed"
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
# output:'branch closed'
print(x.open_branch())
# output: 'branch opened'
add a comment |
The two print statements at the end are only printing the returned results of the method:
print(y.open_branch())
print(x.open_branch())
Since python returns None
by default if you don't explicitly specify a return statement, and you are calling the methods twice, then it's expected that you see two None
statements.
If you call the method without print, you will see a single printed message.
y.open_branch()
x.open_branch()
You could improve your code by adding return statements within the method and doing the print outside, as you are doing right now. Something like
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
return "branch opened"
return "branch closed"
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
# output:'branch closed'
print(x.open_branch())
# output: 'branch opened'
add a comment |
The two print statements at the end are only printing the returned results of the method:
print(y.open_branch())
print(x.open_branch())
Since python returns None
by default if you don't explicitly specify a return statement, and you are calling the methods twice, then it's expected that you see two None
statements.
If you call the method without print, you will see a single printed message.
y.open_branch()
x.open_branch()
You could improve your code by adding return statements within the method and doing the print outside, as you are doing right now. Something like
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
return "branch opened"
return "branch closed"
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
# output:'branch closed'
print(x.open_branch())
# output: 'branch opened'
The two print statements at the end are only printing the returned results of the method:
print(y.open_branch())
print(x.open_branch())
Since python returns None
by default if you don't explicitly specify a return statement, and you are calling the methods twice, then it's expected that you see two None
statements.
If you call the method without print, you will see a single printed message.
y.open_branch()
x.open_branch()
You could improve your code by adding return statements within the method and doing the print outside, as you are doing right now. Something like
class Restaurant(object):
bankrupt = False
def open_branch(self):
if not self.bankrupt:
return "branch opened"
return "branch closed"
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
# output:'branch closed'
print(x.open_branch())
# output: 'branch opened'
edited Nov 15 '18 at 12:13
answered Nov 15 '18 at 10:31
MedAliMedAli
7,14874182
7,14874182
add a comment |
add a comment |
What you're doing is you're calling print
on the return value of open_branch
.
So when you see it print None
, you're seeing the outcome of print(x.open_branch()
and print(y.open_branch()
.
When you see branch opened
, that's the result of the print inside open_branch
.
Try this:
class Restaurant(object):
bankrupt = False
def open_branch(self):
result = ""
if self.bankrupt:
result = "Restaurant is bankrupt"
else:
result = "Branch opened"
return result
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
print(x.open_branch())
add a comment |
What you're doing is you're calling print
on the return value of open_branch
.
So when you see it print None
, you're seeing the outcome of print(x.open_branch()
and print(y.open_branch()
.
When you see branch opened
, that's the result of the print inside open_branch
.
Try this:
class Restaurant(object):
bankrupt = False
def open_branch(self):
result = ""
if self.bankrupt:
result = "Restaurant is bankrupt"
else:
result = "Branch opened"
return result
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
print(x.open_branch())
add a comment |
What you're doing is you're calling print
on the return value of open_branch
.
So when you see it print None
, you're seeing the outcome of print(x.open_branch()
and print(y.open_branch()
.
When you see branch opened
, that's the result of the print inside open_branch
.
Try this:
class Restaurant(object):
bankrupt = False
def open_branch(self):
result = ""
if self.bankrupt:
result = "Restaurant is bankrupt"
else:
result = "Branch opened"
return result
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
print(x.open_branch())
What you're doing is you're calling print
on the return value of open_branch
.
So when you see it print None
, you're seeing the outcome of print(x.open_branch()
and print(y.open_branch()
.
When you see branch opened
, that's the result of the print inside open_branch
.
Try this:
class Restaurant(object):
bankrupt = False
def open_branch(self):
result = ""
if self.bankrupt:
result = "Restaurant is bankrupt"
else:
result = "Branch opened"
return result
x = Restaurant()
y = Restaurant()
y.bankrupt = True
print(y.open_branch())
print(x.open_branch())
answered Nov 15 '18 at 10:29
John Go-SocoJohn Go-Soco
40129
40129
add a comment |
add a comment |
There are a few things that are giving you issues here:
Your
open_branch
function isn't returning anything, so when you callprint(self.open_branch(x))
it's printingNone
, which is what all functions in Python return by default if there is noreturn
statement. You can solve this issue by replacingif not self.bankrupt:
print("branch opened")with
if not self.bankrupt:
return "branch opened"You're calling
print
three times, which is why you're getting three lines printed on the console (although this will resolve itself if you replace theprint
in the function with thereturn
statement I detailed above).You should put an
else
statement under yourif
clause, so that it will return something useful (instead ofNone
ifself.bankrupt == True
) and you can tell if the branch was opened or not. I'd suggest something like:if not self.bankrupt:
return "branch opened"
else:
return "Restaurant is bankrupt, branch could not be opened"
add a comment |
There are a few things that are giving you issues here:
Your
open_branch
function isn't returning anything, so when you callprint(self.open_branch(x))
it's printingNone
, which is what all functions in Python return by default if there is noreturn
statement. You can solve this issue by replacingif not self.bankrupt:
print("branch opened")with
if not self.bankrupt:
return "branch opened"You're calling
print
three times, which is why you're getting three lines printed on the console (although this will resolve itself if you replace theprint
in the function with thereturn
statement I detailed above).You should put an
else
statement under yourif
clause, so that it will return something useful (instead ofNone
ifself.bankrupt == True
) and you can tell if the branch was opened or not. I'd suggest something like:if not self.bankrupt:
return "branch opened"
else:
return "Restaurant is bankrupt, branch could not be opened"
add a comment |
There are a few things that are giving you issues here:
Your
open_branch
function isn't returning anything, so when you callprint(self.open_branch(x))
it's printingNone
, which is what all functions in Python return by default if there is noreturn
statement. You can solve this issue by replacingif not self.bankrupt:
print("branch opened")with
if not self.bankrupt:
return "branch opened"You're calling
print
three times, which is why you're getting three lines printed on the console (although this will resolve itself if you replace theprint
in the function with thereturn
statement I detailed above).You should put an
else
statement under yourif
clause, so that it will return something useful (instead ofNone
ifself.bankrupt == True
) and you can tell if the branch was opened or not. I'd suggest something like:if not self.bankrupt:
return "branch opened"
else:
return "Restaurant is bankrupt, branch could not be opened"
There are a few things that are giving you issues here:
Your
open_branch
function isn't returning anything, so when you callprint(self.open_branch(x))
it's printingNone
, which is what all functions in Python return by default if there is noreturn
statement. You can solve this issue by replacingif not self.bankrupt:
print("branch opened")with
if not self.bankrupt:
return "branch opened"You're calling
print
three times, which is why you're getting three lines printed on the console (although this will resolve itself if you replace theprint
in the function with thereturn
statement I detailed above).You should put an
else
statement under yourif
clause, so that it will return something useful (instead ofNone
ifself.bankrupt == True
) and you can tell if the branch was opened or not. I'd suggest something like:if not self.bankrupt:
return "branch opened"
else:
return "Restaurant is bankrupt, branch could not be opened"
edited Nov 15 '18 at 11:31
answered Nov 15 '18 at 10:38
CromulentCromulent
781212
781212
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53317230%2fpython-printing-thrice-while-i-called-the-function-twice-why-is-this-so%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Youre printing the return value of the function which is none
– Antti Haapala
Nov 15 '18 at 10:24
2
You're calling print thrice
– Antti Haapala
Nov 15 '18 at 10:24
Worth noting this would print 3 times in JS as well.
– kabanus
Nov 15 '18 at 10:24
i really dont get it. where am i calling thrice ? i just wrote print print(y.open_branch()) && print(x.open_branch())
– Sanjida lina
Nov 15 '18 at 10:28
1
print("branch opened")
—print(y.open_branch())
—print(x.open_branch())
— That's three.– khelwood
Nov 15 '18 at 10:30