Tell us what’s happening:
The 1st part got okay-ish but then the last requirement i need to fulfil are quite a challenge
Like I cannot seem to find out how to add a dash to it or how to add the 4 spaces and the dashes together.
Could use some help here. Your code so far
def arithmetic_arranger(problems):
x = input("Enter a number")
y = input("Enter a + or -")
z = input("Enter another number")
if(problems > 6) #exceeds the maxinum problem of 5 assigned to the function
print( "Error: Too many problems.")
elif(y !== + OR -)#anything else other then a + or - is used by user
print("Error: Operator must be '+' or '-'")
elif(y != int OR x != int)#only numbers
print("Error: Numbers must only contain digits.")
elif(x OR z > 5)#Each operand (aka number on each side of the operator) has a max of four digits in width. Otherwise, the error string returned will be:
print("Error: Numbers cannot be more than four digits.")
else()
print(x /n, y /n, z /n)
#Numbers should be right-aligned. = f"{number:>width}"
#4 spaces /n
#dashes i can't find those google return me to a program Dash
return arranged_problems
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36.
def arithmetic_arranger(problems):
#Something wrong here i'm misunderstanding something what must be inputed
x = input("Enter a number")
y = input("Enter a + or -")
z = input("Enter another number")
if(problems > 6) #exceeds the maxinum problem of 5 assigned to the function
print( "Error: Too many problems.")
elif(y !== + OR -)#anything else other then a + or - is used by user
print("Error: Operator must be '+' or '-'")
elif(y != int OR x != int)#only numbers
print("Error: Numbers must only contain digits.")
elif(x OR z > 5)#Each operand (aka number on each side of the operator) has a max of four digits in width. Otherwise, the error string returned will be:
print("Error: Numbers cannot be more than four digits.")
else()
b = x, y ,z
a = b.split()
print(a)
return arranged_problems
#the full task https://repl.it/@freeCodeCamp/fcc-arithmetic-arranger#README.md
def arithmetic_arranger(problems):
l = len(problems)
for p in problems:
x,y,z = p.split()
x = int(x)
z = int(z)
if(l > 5) : #exceeds the maxinum problem of 5 assigned to the function
print( "Error: Too many problems.")
elif y != '+' or y != '-':#anything else other then a + or - is used by user
print("Error: Operator must be '+' or '-'")
elif(type(x) != int or type(z) != int):#only numbers
print("Error: Numbers must only contain digits.")
elif(x or z > 5):#Each operand (aka number on each side of the operator) has a max of four digits in width. Otherwise, the error string returned will be:
print("Error: Numbers cannot be more than four digits.")
else:
pass
return arranged_problems
print(arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"]))
def arithmetic_arranger(problems):
l = len(problems)
for p in problems:
x,y,z = p.split()
x = int(x)
z = int(z)
if(l > 6) : #exceeds the maxinum problem of 5 assigned to the function
print( "Error: Too many problems.")
elif y != '+' or y != '-':#anything else other then a + or - is used by user
print("Error: Operator must be '+' or '-'")
elif(type(x) != int or type(z) != int):#only numbers
print("Error: Numbers must only contain digits.")
elif(x or z > 6):#Each operand (aka number on each side of the operator) has a max of four digits in width. Otherwise, the error string returned will be:
print("Error: Numbers cannot be more than four digits.")
else:
pass
return arranged_problems
print(arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123