Tell us what’s happening:
Am I the only one who understands that we’re supposed use a list of strings for the initial argument? That said, when I convert the string to int, the operators can’t function. Furthermore, each string in the list is a single index, so when I split the list to print vertically, it stacks the problems rather than arranging them sideways. Any advice on the conversion from a list of str to individual ints with usable operators would most helpful. A better way to split the list would also be great. Thanks.
Your code so far
Here’s some of my code, but understand I’ve been writing and re-writing, so whatever’s there is not necessarily complete:
def arithmetic_arranger(problems, calc: bool = True) -> None: #split list by commas for item in problems: return(problmes.replace(",", "\n")) #create error for input other than str #for item in problems: #try: #[""] #except: #print("Error, input list of string type only") #limit digit input to 4 digits #create an error if the problems exceed 5 if len(problems) < 6: return problems else: print("Error, too many problems") #print list vertically for item in range(len(problems)): for x in problems: return(x[item]) #convert and caluclate """while calc is True: conversion = () for op in conversion: if op in conversion == "+" return num1 + num2 elif op in conversion == "-": return num1 - num2 else: print("Error use + or - operators only")""" print(arithmetic_arranger(["1 + 2"]))
Your browser information:
User Agent is:
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36.
Challenge: Arithmetic Formatter
Link to the challenge: