2023年 3月 18日

Python打印1到100的所有奇数

1 需求

使用Python中的循环打印输出从1到100的所有奇数。

2 代码实现

class Solution:

    def PrintTheOdd(self):
        index = 1
        while index <= 100:
            print(index)
            index += 1


if __name__ == "__main__":
    solution = Solution()
    solution.PrintTheOdd()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12