Help required over a confusion - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: News and Discussions (https://python-forum.io/forum-31.html) +--- Thread: Help required over a confusion (/thread-16767.html) |
Help required over a confusion - sunnyarora - Mar-13-2019 Hi, I just want to know that why we don't use == operator with while / for loop? RE: Help required over a confusion - Yoriz - Mar-13-2019 Feel free to use == any where an equality check is needed. RE: Help required over a confusion - sunnyarora - Mar-13-2019 Thanks but pycharm is showing error while using this in a code ; x=0 while (x>==0): print(x) RE: Help required over a confusion - Yoriz - Mar-13-2019 Because that is not == you want just >= not >==. RE: Help required over a confusion - sunnyarora - Mar-13-2019 That's the reason i m getting confuse .. scenarios are; 1) if we use while (x==10)----it works perfectly. 20 But if we use while (x<=10)-----this shows error to not to use double is equal to sign. Confusion is why we dont use double == sign while using with another operator whereas if we use == independently then no error... RE: Help required over a confusion - ichabod801 - Mar-13-2019 == is used to distinguish the operator from assignment, where = is used. We don't need to distinguish >= from =, because they are obviously different, so we don't use >==. RE: Help required over a confusion - Yoriz - Mar-13-2019 Maybe your thinking because < is less than and == is equal that you could combine them to make less than or equal. They are set symbols that are used individually. #Operation Meaning < #strictly less than <= #less than or equal > #strictly greater than >= #greater than or equal == #equal != #not equal is #object identity is not #negated object identity RE: Help required over a confusion - sunnyarora - Mar-13-2019 Thanks Sir, got the point. |