My file look that:
abc 1
bca 2
How to get texts(abc and bca) and append to array and get numbers and append to another array?
I made this:
plik = open("testcase.txt", "r")
imie = []
dlugosc = []
for line in plik:
for word in line.split():
imie.append(word)
Now when i print "imie" that shows everythinkg.
>Solution :
you can try this to check digit
a_string = "abc 1 bca 2"
numbers = []
for word in a_string.split():
if word.isdigit():
numbers.append(int(word))
print(numbers)
OUTPUT : [1,2]