I use the following code to create 2 lists, nameList and class List.
nameList[] gradeList[] for row in soup.find_all('tr'): name = row.select('th strong') grade = row.select('td label') if grade and name: if "/" in grade[0].text: gradeList.append(grade[0].text) nameShort = re.sub(r'^(.{20}).*$', '\g<1>...', str(name[0].text)) nameList.append(nameShort)
Produce something like:
nameList = ["grade 1","grade 2222222222","grade 3"] gradeList = ["1/1","2/2","100000/100000"]
I want the program to print lists in 2 blank columns side by side. In each column, I want the data aligned to the left. Lists (required) will always be uniformly filled. The first column (nameList) will never be longer than 25 characters. What I'm looking for will look like the following:
Assignment Grade 0 grade 1 1/1 1 grade 2222222222 2/2 2 grade 3 100000/100000
I tried using pandas and it worked, but the formatting was strange and inappropriate. It will not align to the left as I want. I believe this happened because each of this data has a different character length in both lists (shown above).
source share