Python Forum
simple if elif conditions in Python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: simple if elif conditions in Python (/thread-23609.html)



simple if elif conditions in Python - Chandan - Jan-08-2020

Hi There,
I am very much new to Python and to this forum. I am looking for code help.
I have a SAS code as below and I would like to replicate this in Python.
It would be great if you guys can assist me with this.

if Universtiy in ("name1","name2","name3") then Universtiy_Group='Go8 University';
else if University in ("name4","name5") then Universtiy_Group='Eligible Go8 University';
else Universtiy_Group="Others";

Kind regards,
CK


RE: simple if elif conditions in Python - ichabod801 - Jan-08-2020

if Universtiy in ("name1","name2","name3"):
    Universtiy_Group = 'Go8 University'
elif University in ("name4","name5"):
    Universtiy_Group = 'Eligible Go8 University'
else:
    Universtiy_Group = "Others"
Note the indentation. While indentation is ignored by SAS, it is part of the syntax in Python.


RE: simple if elif conditions in Python - DeaD_EyE - Jan-08-2020

university = "name1"

if university in ("name1", "name2", "name3"):
    university_group = "Go8 University"
elif university in ("name4","name5"):
    university_group = "Eligible Go8 University"
else:
    university_group = "Others"