Can't understand why the code shows incorrect output. The output should be 1 and yes but instead of yes it shows NoConvert bytes to a string?Filters in Python3Why Is the Output of My Range Function Not a List?zip function giving incorrect outputWhy does list in program give an unexpected output?Python zip function - weird resultWhy is output not printing a list?python code running else statement even after if statement is trueWhy is the else statement in this code not working?Concatenate arrays in Python - output error

Can I enter the UK without my husband if we said we'd travel together in our visa application?

Is it acceptable to say that a reviewer's concern is not going to be addressed because then the paper would be too long?

Convex hull in a discrete space

What does Sartre mean by "pédéraste" - pederast or homosexual?

Difference between "rip up" and "rip down"

Number of list elements less than a given integer

Why was it decided in 1956 to abolish the spelling чорт (devil) in favor of чёрт?

I reverse the source code, you reverse the input!

What does מעלה עליו הכתוב mean?

How to check if my quadrature encoder is broken or not?

Is the order of words purely based on convention?

Why, even after his imprisonment, people keep calling Hannibal Lecter "Doctor"?

What exactly did this mechanic sabotage on the American Airlines 737, and how dangerous was it?

New road bike: alloy dual pivot brakes work poorly

Why are there two fundamental laws of logic?

Flowers sent by the birds

Align all symbols in a LaTeX equation

Why is STARTTLS still used?

Designing a time thief proof safe

Help in drawing resonance structures in case of polybasic acids

Why is a road bike faster than a city bike with the same effort? How much faster it can be?

Comma Code - Automate the Boring Stuff with Python

Seventh degree polynomial

Is a Middle Name a Given Name?



Can't understand why the code shows incorrect output. The output should be 1 and yes but instead of yes it shows No


Convert bytes to a string?Filters in Python3Why Is the Output of My Range Function Not a List?zip function giving incorrect outputWhy does list in program give an unexpected output?Python zip function - weird resultWhy is output not printing a list?python code running else statement even after if statement is trueWhy is the else statement in this code not working?Concatenate arrays in Python - output error






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Iam learning python and wanted to test the concept of list and if/else function.



num1 = ["1"]
c = num1[0]
print(c)
if num1[0] == 1:
print("yes")
else:
print("no")


I expect the output to be 1 yes
but I get the output as 1 no
why does it not enter if block even when the condition is met










share|improve this question
































    0















    Iam learning python and wanted to test the concept of list and if/else function.



    num1 = ["1"]
    c = num1[0]
    print(c)
    if num1[0] == 1:
    print("yes")
    else:
    print("no")


    I expect the output to be 1 yes
    but I get the output as 1 no
    why does it not enter if block even when the condition is met










    share|improve this question




























      0












      0








      0








      Iam learning python and wanted to test the concept of list and if/else function.



      num1 = ["1"]
      c = num1[0]
      print(c)
      if num1[0] == 1:
      print("yes")
      else:
      print("no")


      I expect the output to be 1 yes
      but I get the output as 1 no
      why does it not enter if block even when the condition is met










      share|improve this question
















      Iam learning python and wanted to test the concept of list and if/else function.



      num1 = ["1"]
      c = num1[0]
      print(c)
      if num1[0] == 1:
      print("yes")
      else:
      print("no")


      I expect the output to be 1 yes
      but I get the output as 1 no
      why does it not enter if block even when the condition is met







      python-3.x






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 19:18









      Paandittya

      6395 silver badges16 bronze badges




      6395 silver badges16 bronze badges










      asked Mar 28 at 18:41









      Prnv_atPrnv_at

      1




      1

























          1 Answer
          1






          active

          oldest

          votes


















          3
















          Arent you comparing string with integer? try if (num[0]=="1")






          share|improve this answer



























            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/4.0/"u003ecc by-sa 4.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
            );



            );














            draft saved

            draft discarded
















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404763%2fcant-understand-why-the-code-shows-incorrect-output-the-output-should-be-1-and%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3
















            Arent you comparing string with integer? try if (num[0]=="1")






            share|improve this answer





























              3
















              Arent you comparing string with integer? try if (num[0]=="1")






              share|improve this answer



























                3














                3










                3









                Arent you comparing string with integer? try if (num[0]=="1")






                share|improve this answer













                Arent you comparing string with integer? try if (num[0]=="1")







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 18:44









                MurksiukeMurksiuke

                315 bronze badges




                315 bronze badges

































                    draft saved

                    draft discarded















































                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404763%2fcant-understand-why-the-code-shows-incorrect-output-the-output-should-be-1-and%23new-answer', 'question_page');

                    );

                    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







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현