-3

I cannot describe clearly because English is not my native language

If I input like this

a = 4252

Then I want to take each number component, it should be like this

a1=4; a2=2; a3=5; a4=2

How to do that in python? If you know it has a similar question in stackoverflow, give me a link

1 Answers1

1

Convert the integer to a string for easy iterability then get the int value of every character like this: a1,a2,a3,a4 = [int(elem) for elem in str(a)]

Zingerella
  • 450
  • 2
  • 11