Why can't use semi-colon before for loop in Python? -
i can bring together lines in python using semi-colon, e.g.
a=5; b=10 but why can't same for
x=['a','b']; i,j in enumerate(x): print(i,":", j)
the short (yet valid) reply "because language grammar isn't defined allow it". why that's case, it's hard if not impossible sure unless inquire whoever came portion of grammar, imagine it's due readability, 1 of goals of python1.
why ever want write obscure that? split multiple lines:
x = ['a','b'] i,j in enumerate(x): print(i, ":", j) i argue variant much clearer.
1 import this: readability counts.
python
No comments:
Post a Comment