Answer the question
In order to leave comments, you need to log in
How to fix TypeError: 'type' object is not subscriptable?
with open('input.txt', 'r') as f:
num = list(map(int, f.read().split()))
num = list(map[int, f.read().split()])
that is, I rewrite it in a regular list, then it writes an error . I couldn't find an answer on the internet that worked for me.... TypeError: 'type' object is not subscriptable
Answer the question
In order to leave comments, you need to log in
Ufff. Here we are talking about the basics of Python syntax.
Your first code does the following.
num = list( #построить список из последовательности
map( #вызываем функцию map()
int, #первый параметр
f.read().split() #второй параметр
)
)
num = list( #построить список из последовательности
map[ #обращаемся к объекту map и пытаемся получить значение по ключу
int, #первый элемент кортежа-ключа
f.read().split() #второй элемент кортежа-ключа
]
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question