python check string or number array

Solutions on MaxInterview for python check string or number array by the best coders in the world

showing results for - "python check string or number array"
Elyza
11 Jul 2017
1numbers = []
2animals = []
3with open('textfile.txt') as f:
4    for x in f:
5        try:
6            numbers.append(int(x.replace("\n", "")))
7        except:
8            animals.append(str(x.replace("\n", "")))
9print(numbers)
10print(animals)
11
12# Output
13# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
14# ['dog', 'cat', 'fish', 'bird']
queries leading to this page
split values in array pythoncheck if array contain number pythonhow to add string to array in pythonhow to add string into array pythonadd sting to array pythonsplit number into array pythonpython string split arrayhow to append string and arrays to an array pythoncheck if string in array pythonpython check if number in arraypython split string in arraypython add stringg to arraypython check string in arraypython check if string lies in arraypython add string to arraycheck if number in array pythonsplit string into array pythonadd string to an array pythoncheck if array intercet pythonpython insert string in arrayadd array of string to array pythonhow to check if a string contain an array of values pythonadd values of array to string in pythonappend string of python array check if value is array pythonpython split arraypython split string into arraypython check array for stringcheck if string not in array pythonsplit text in array pythonadd string in array pythoncheck if array elements not in string pythoncheck if it 27s a string or array pythoncheck if string is not their in array of strings pythonpython test if string or arraypython check if string present in array of stringspython check if type is string arrayadd elements in string array pythonpython check string or number arraypython split values with otsu arraycheck if variable is array or string in pythonpython check if string is in arraycheck if a string is in array pythonseparate numbers and strings into array pythonsplit string and put it into an array pythonadd element to string array pythonpython check string or number array