I am a python newbie so am writing small programs to get more familiar. I have a rasp PI to, very unix skilled,done programming but not python3. One of these is a simple bubble sort, it reads in two txt files with numbers 5 9 2 19 18 17 13 and another with different numbers 10 14 2 4 6 20 type thing
I use a function to read in each file then join them before I bubblesort the whole string, I'm aware it needs to be a list so that the bubblesort function can move the numbers around during each pass. From what I can tell my issue is the mergesort (var name for the concatenated list) always is a string.
Anyone shed any light on why this is so? and how could I convert the two files into a single list? ------------------sample code-------------------
mergesort = []
def readfile1():
tempfile1 = open('sortfile1.txt','r')
tempfile1 = tempfile1.read()
return tempfile1
def readfile2():
tempfile2 = open('sortfile2.txt','r')
tempfile2 = tempfile2.read()
return tempfile2
sortstring1 = readfile1()
# print (sortstring1)
sortstring2 = readfile2()
# print (sortstring2)
# mergesort = list(set(sortstring1) | set(sortstring2)
mergesort = sortstring1 + sortstring2
print (mergesort, "Type=", type(mergesort))