I am trying to make a little game in python but somethings not working [duplicate]
up vote
-3
down vote
favorite
This question already has an answer here:
input from user
4 answers
This is the code:
secret_number = 7
guess = input("What number am i thinking of?")
if secret_number == guess:
print("Yay you got it")
else:
print("No that's not it")
When I run the code I always get "No that's not it" even if I guessed the right number.
python python-3.x
marked as duplicate by petezurich, Prune
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 7 at 23:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
-3
down vote
favorite
This question already has an answer here:
input from user
4 answers
This is the code:
secret_number = 7
guess = input("What number am i thinking of?")
if secret_number == guess:
print("Yay you got it")
else:
print("No that's not it")
When I run the code I always get "No that's not it" even if I guessed the right number.
python python-3.x
marked as duplicate by petezurich, Prune
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 7 at 23:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
secret_number = '7'
will make it work. See the difference? Check the documentation ofinput
for why this is so.
– usr2564301
Nov 7 at 22:58
input
returns a string. So the string'7'
and the number7
are not equivalent.
– Spencer Wieczorek
Nov 7 at 23:00
add a comment |
up vote
-3
down vote
favorite
up vote
-3
down vote
favorite
This question already has an answer here:
input from user
4 answers
This is the code:
secret_number = 7
guess = input("What number am i thinking of?")
if secret_number == guess:
print("Yay you got it")
else:
print("No that's not it")
When I run the code I always get "No that's not it" even if I guessed the right number.
python python-3.x
This question already has an answer here:
input from user
4 answers
This is the code:
secret_number = 7
guess = input("What number am i thinking of?")
if secret_number == guess:
print("Yay you got it")
else:
print("No that's not it")
When I run the code I always get "No that's not it" even if I guessed the right number.
This question already has an answer here:
input from user
4 answers
python python-3.x
python python-3.x
asked Nov 7 at 22:57
C. Hengst
32
32
marked as duplicate by petezurich, Prune
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 7 at 23:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by petezurich, Prune
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 7 at 23:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
secret_number = '7'
will make it work. See the difference? Check the documentation ofinput
for why this is so.
– usr2564301
Nov 7 at 22:58
input
returns a string. So the string'7'
and the number7
are not equivalent.
– Spencer Wieczorek
Nov 7 at 23:00
add a comment |
secret_number = '7'
will make it work. See the difference? Check the documentation ofinput
for why this is so.
– usr2564301
Nov 7 at 22:58
input
returns a string. So the string'7'
and the number7
are not equivalent.
– Spencer Wieczorek
Nov 7 at 23:00
secret_number = '7'
will make it work. See the difference? Check the documentation of input
for why this is so.– usr2564301
Nov 7 at 22:58
secret_number = '7'
will make it work. See the difference? Check the documentation of input
for why this is so.– usr2564301
Nov 7 at 22:58
input
returns a string. So the string '7'
and the number 7
are not equivalent.– Spencer Wieczorek
Nov 7 at 23:00
input
returns a string. So the string '7'
and the number 7
are not equivalent.– Spencer Wieczorek
Nov 7 at 23:00
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Your input comes in string
value by default. You have to convert it to int
in order to work.
guess =
int
(input("What number am i thinking of?"))
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Your input comes in string
value by default. You have to convert it to int
in order to work.
guess =
int
(input("What number am i thinking of?"))
add a comment |
up vote
1
down vote
accepted
Your input comes in string
value by default. You have to convert it to int
in order to work.
guess =
int
(input("What number am i thinking of?"))
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Your input comes in string
value by default. You have to convert it to int
in order to work.
guess =
int
(input("What number am i thinking of?"))
Your input comes in string
value by default. You have to convert it to int
in order to work.
guess =
int
(input("What number am i thinking of?"))
answered Nov 7 at 23:02
Alex Sherzhukov
261
261
add a comment |
add a comment |
secret_number = '7'
will make it work. See the difference? Check the documentation ofinput
for why this is so.– usr2564301
Nov 7 at 22:58
input
returns a string. So the string'7'
and the number7
are not equivalent.– Spencer Wieczorek
Nov 7 at 23:00