I am creating a sequence identifier and I want a shorter code by manipulating the list. However:
#This is possible:
list = [1,2,3,4,5]
A = list[1] - list[0]
print(A)
#This is not possible:
list = [input()]
A = list[1] - list[0]
print(A)
I am creating a sequence identifier and I want a shorter code by manipulating the list. However:
#This is possible:
list = [1,2,3,4,5]
A = list[1] - list[0]
print(A)
#This is not possible:
list = [input()]
A = list[1] - list[0]
print(A)
[input()]
is only one (string) element, so list[1]
doesn't exist to be used in subtraction.
If you want a list of 5 user-entered integers, you would use
[int(input()) for _ in range(5)]
And press enter after each value
Or for space-separated values - [int(x) for x in input().split()]