Oct-11-2020, 09:24 AM
(Something has changed here, I can't seem to mark Python code as code. Sorry!)
I was just looking at this, but I cannot understand what this part really does:
Why would I need the above? Why not just put:
n = 100
for i in range(n, 0, -1) ??
I was just looking at this, but I cannot understand what this part really does:
n = 100 if sys.argv[1:]: n = int(sys.argv[1])That is to say, I don't understand the purpose of sys.argv or what exactly this does:
Quote:if sys.argv[1:]:
Why would I need the above? Why not just put:
n = 100
for i in range(n, 0, -1) ??
def myApp(): import sys n = 100 if sys.argv[1:]: n = int(sys.argv[1]) def bottle(n): if n == 0: return "no more bottles of beer" if n == 1: return "one bottle of beer" return str(n) + " bottles of beer" for i in range(n, 0, -1): print(bottle(i), "on the wall,") print(bottle(i) + ".") print("Take one down, pass it around,") print(bottle(i-1), "on the wall.")