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.










share|improve this question













marked as duplicate by petezurich, Prune python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

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 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















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.










share|improve this question













marked as duplicate by petezurich, Prune python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

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 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













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.










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 7 at 22:57









C. Hengst

32




32




marked as duplicate by petezurich, Prune python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

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 python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

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 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


















  • 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
















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












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?"))






share|improve this answer




























    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?"))






    share|improve this answer

























      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?"))






      share|improve this answer























        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?"))






        share|improve this answer












        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?"))







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 7 at 23:02









        Alex Sherzhukov

        261




        261















            這個網誌中的熱門文章

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud

            Zucchini