It takes an input n and outputs the numbers from 1 to n.
For each multiple of 3, print "Solo" instead of the number.
For each multiple of 5, prints "Learn" instead of the number.
For numbers which are multiples of both 3 and 5, output "SoloLearn".
You need to change the code to skip the even numbers, so that the logic only applies to odd numbers in the range.
Answers
Answered by
2
def main(i):
if i % 2 == 0:
return
if i % 3 == 0 and i % 5 == 0:
return "SoloLearn"
if i % 3 == 0:
return "Solo"
if i % 5 == 0:
return "Learn"
return i
n = int(input("n: "))
print("\n".join([str(x) for x in map(main, range(1, n + 1)) if x is not None]))
Similar questions