I am starting to study in Python now through the book “How to Think Like a Computer Scientist” From an exercise from a book on encoded conventions, the syntax taught is:
def function(x,y)
if ..:
print ".."
elif..:
print ".."
else:
print".."
However, when I tried this to find out if its legal, it worked:
def function (x,y)
if ..:
print ".."
if ..:
print ".."
Is the latter the correct syntax? Or is it not even considered conditional? I would like to know that even if it is legal in Python, is it a “good way” to write code?
Any help is truly appreciated.
source
share