I'm asking you how to change all the characters in the list ('1', '2',...) to numbers without a for statement

Asked 1 years ago, Updated 1 years ago, 92 views

['1', '2', '3'] -> [1, 2, 3]

How do I turn a number stored in text into a number?

I think there is a way to do it without using the for statement, but I don't know what to do.

list android-intent python conversion

2022-09-21 16:41

1 Answers

Usually, int('1') is used to make 1' into 1. Use map() to apply this to the entire list without using for.

map(function, iterable,...) is a function that returns an interpreter that applies function to all items in iterable.

results = map(int, results)


2022-09-21 16:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.