555
554
33
2444
4555
2455
24555
2555
2335
5555
23455
2455
2344
I want to store all these values in the single variable num, how can I do that?
If you are working with a multiple line string you can use split
given "\n"
as the splitor:
myString = """
555
554
33
2444
4555
2455
24555
2555
2335
5555
23455
2455
2344
"""
myString.strip().split("\n")
['555',
'554',
'33',
'2444',
'4555',
'2455',
'24555',
'2555',
'2335',
'5555',
'23455',
'2455',
'2344']
Note that if you are working with file, you can still use the same approach, but you need to read the file first.