0

I have been practising some coding on leetcode, and I found a line of code to step through an array, pull out each number and put it into an array of strings.

digits = [1,2,3,4]
string_ints = [str(ints) for ints in digits]

The bit I am confused about is "str(int)", is it declaring a variable of type string with the value "ints"? How is this accepted when "ints" is called before it is declared in the for loop? Is this another way to declare a variable?

Is someone able to explain the entire line?

This outputs ['1', '2', '3', '4']

Thanks

0 Answers0