1 year ago
#371145
Kyhree Armstead
How do I print these vertical problems, horizontally?
I'm trying to make horizontal problems vertical, then print those vertical problems horizontally. If that makes sense...
I tried doing the for i in (list): print(I, end = " ")
but that just makes it come out like stairs. I expected it to come out horizontal.
Here's what I have for now:
problems = \["57 + 8", "33 - 145", "11 - 6"\]
def aaaa(y):
altprobs = []
das = "-"
first = " "
second = " "
for piece in y:
fn = piece.split(" ")[0]
op = piece.split(" ")[1]
sn = piece.split(" ")[2]
leng = max(len(fn), len(sn))
if leng == len(sn):
leng = leng + 2
first = fn.rjust(leng)
string = first+"\n"+op+" "+sn+"\n"+das*leng
elif leng == len(fn):
leng = leng + 2
first = fn.rjust(leng)
second = op+" "+sn.rjust(leng-2)
string = first+"\n"+second+"\n"+das*leng
print(string)
print(aaaa(problems))
python-3.x
function
printing
helper
0 Answers
Your Answer