0

I am new at python started learning it from scratch a few days ago , I was trying to build a simple program

if unit != 'i' or 'c'  :
                        print("Wrong unit : Choose 'i' or 'c' only") 

I hope you understand what i want to do by seeing the code

That is not the correct way to do it because i am not getting the desired output Please suggest me something . Any help would be appreciated .

  • 2
    `if unit != 'i' and unit != 'c'` – Bathsheba May 27 '22 at 12:53
  • 1
    `if unit not in {'c', 'i'}:` – Matthias May 27 '22 at 12:57
  • Also i want to know about indents sometimes i get Indentation error – Bhavishya Yadav May 27 '22 at 12:58
  • Thanks for your replies guys finally my program worked correctly . Thanks !! – Bhavishya Yadav May 27 '22 at 13:02
  • @BhavishyaYadav: That's an entirely unrelated question. Short answer: Make sure you use a reasonable IDE that supports language sensitive auto-indent, and configure it to use four-space indents and consistently expand all tabs to four spaces (following PEP8 style guide). Running through any proper Python tutorial will explain why indentation must be consistent; Python is whitespace sensitive, so inconsistent indentation means it literally has no idea where blocks begin and end. – ShadowRanger May 27 '22 at 13:02
  • If you present the actual code that gives the indentation error we can maybe help. But you seem to be asking for a basic tutorial. That is off-topic for SO. This excerpt from the official tutorial (which you should read in before and in preference to any 3rd-party tutorial, blog, or video) may help: https://docs.python.org/3/faq/design.html?highlight=indentation#why-does-python-use-indentation-for-grouping-of-statements – BoarGules May 27 '22 at 13:16

0 Answers0