Sep-03-2018, 04:42 PM
I'm using python3.7.
In this first example it runs without errors.
My goal is to print the numbers in one row and the letters on the second row (or visa versa) aligned in columns. Zero over "a", one over "b", etc.
I would like help in understanding the python logic so I can achieve my goal.
In this first example it runs without errors.
My goal is to print the numbers in one row and the letters on the second row (or visa versa) aligned in columns. Zero over "a", one over "b", etc.
I would like help in understanding the python logic so I can achieve my goal.
numbers = [0,1,2,3,4,5,6,7,8,9] letters = ["a","b","c","d","e","f","g","h","i","j"] for row in range(2): for col in range(10): for num in numbers: print(num, end='') fir let in letters: print(let, end='') print()
Output:0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij
0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij
This next example does not run, but does error.numbers = [0,1,2,3,4,5,6,7,8,9] letters = ["a","b","c","d","e","f","g","h","i","j"] for row in range(2): for col in range(10): for num in numbers: if row==0 and col==0: print(num, end='') else: print(letters, end='') print()
Error:tut1.py, line 16
else:
^
TabError: inconsistent use of tabs and spaces in indentation