4th Sep 2022, 4:44 PM
Bezu Tadesse
Bezu Tadesse - avatar
3 Answers
+ 2
from __future__ import annotations # đŸ‘†đŸ»đŸ‘†đŸ» class Solution: def fizzBuzz(self, n: int) -> List[str]: # ans list ans = [] for num in range(1,n+1): divisible_by_3 = (num % 3 == 0) divisible_by_5 = (num % 5 == 0) if divisible_by_3 and divisible_by_5: # Divides by both 3 and 5, add FizzBuzz ans.append("FizzBuzz") elif divisible_by_3: # Divides by 3, add Fizz ans.append("Fizz") elif divisible_by_5: # Divides by 5, add Buzz ans.append("Buzz") else: # Not divisible by 3 or 5, add the number ans.append(str(num)) return ans # đŸ‘‡đŸ»đŸ‘‡đŸ» fb=Solution().fizzBuzz(25) for w in fb: print(w)
4th Sep 2022, 5:17 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 2
n = int(input()) for x in range(1, n, 2): if x % 3 == 0 and x % 5 == 0: print("SoloLearn") elif x % 3 == 0: print("Solo") elif x % 5 == 0: print("Learn") else: print(x)
4th Sep 2022, 4:52 PM
Sreeju
Sreeju - avatar
+ 1
Forgot to import annotations from future Thanks to Prakash Kumar
24th Oct 2022, 7:00 PM
Bezu Tadesse
Bezu Tadesse - avatar