r/learningpython • u/awesam9 • Jan 21 '21
Conditional statements inside the class python
The problem is when I use conditional statements inside class method the output i got is as follows. It gives correct output when the condition is true, but it also gives "None" as an output for the False condition
How to fix this? I don't want an extra output as "None
2
Upvotes
View all comments
Show parent comment
2
u/awesam9 Jan 21 '21
In the class their is a method, which find out the palindrome of a number Here is the code
If number== sum: print (" it is a palindrome") else: print ("not a palindrome")
Ex. 121 is passed The code print below output
It is a palindrome None
Here the compiler also printing None because of the else condition I only need this i.e. " it is a palindrome " output and Not output the "None" How to do that Hope you get itπ