Quantcast
Channel: Active questions tagged feed - Stack Overflow
Viewing all articles
Browse latest Browse all 540

Why is it showing "False" in leetcode while it is showing True while doing it on my own in VSCode

$
0
0

I am new to programming and I tried some of the easy leet code problems. When I run the code on my own it returns the correct boolean value but when I run in leetcode it returns the opposite. Like it returns True in vs code while it returns false in Leetcode. It is a simple program to check if it is a perfect number or not.

class Solution:    def checkPerfectNumber(self, num: int) -> bool:        num = int(input("Enter number: "))        sum = 0        for i in range(1,num):            if num % i == 0:                sum = sum + i        if sum == num:            return True        else:            return False

Viewing all articles
Browse latest Browse all 540

Trending Articles