0
How to get the data type of an input of the form 'x + y' or 'x - y'?
If x or y is not a number, then it should print a message "Enter equation again". If the operator is not '+' or '-' it should print "Enter equation again" But, input() always reads an input as a string. So, how to compare the data type of 'x' and 'y'?
2 Antworten
+ 3
Use split() function and check each single item of input.
Pseudo-Code:
term = input().split()
term[0] = number?
term[1] = + or -?
term[2] = number?
And you do not need data type for x and y. There are string methods to check if it is a letter or a number.
0
So should the printing be all this listed or just compare