не могу понять почему вот этот вот фрагмент кода:
a = [] while True: b = input() if b == 'end': break k = [int(i) for i in b.split()] a.append(k) print(a)
приводит к правильному выводу:
C:\Anaconda3\python.exe “C
____/Python Projects/Stepic.py”1 2 3
4 5 6
7 8 9
end
[, , ]
Process finished with exit code 0
в вот этот (в котором собственно вместо b = input() используется input()):
a = [] while True: if input() == 'end': break k = [int(i) for i in input().split()] a.append(k) print(a)
приводит к ошибке:
C:\Anaconda3\python.exe “C
____/Python Projects/Stepic.py”1 2 3
4 5 6
7 8 9
end
Traceback (most recent call last):
File “C
____/Python Projects/Stepic.py”, line 23, in <module>k =
File “C
____/Python Projects/Stepic.py”, line 23, in <listcomp>k =
ValueError: invalid literal for int() with base 10: ‘end’
Process finished with exit code 1
СОБСТВЕННО вопрос не в том в чём ошибка, а в том какая разница между b = input() и просто input()???