Arithmetic Formatter trivial issue

I am a little bit confused about this:
I just finished [Scientific Computing with Python] course and I am trying to done the first project which is ‘Arithmetic Formatter’, I know it’s a really easy question but should I put the Arithmetic problems or I put an input() method so the user input the values he wants? If it’s like this, how could I make the program understand the values as numbers and count them? (The following code was just some tests so don’t mind about it,)

def art() :
    a = input()
    for s in a :
        c =int(a)
        b = c[0] + c[0]


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36

Challenge: Arithmetic Formatter

Link to the challenge:

The input() will consider everything you enter as a single line of text - a string.
So you have to think about string-operations when dealing with the input → for example a for-in-loop will go character by character, even if the user put in a number.
And you have to think about making the program robust, adding try-except blocks for every operation that could fail for an input → so if the user put in letters or spaces into a number, you want to catch that.

There are also special methods like “exec” and “eval” which can turn strings into Python-code which can be helpful in some scenarios but also runs the RISK of allowing users to input dangerous code.


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.