标签:__name__ poi ber tle 使用方法 less except ror abs
使用方法:输入一个大于0的整数#!/usr/bin/env python # -*- coding: utf-8 -*- def collatz(number): while(number != 1): if number % 2 == 0: number = number // 2 print(number) else: number = 3 * number + 1 print(number) if __name__ == '__main__': try: number = abs(int(input("Enter a number:"))) if number != 0: collatz(number) else: print("Pointless!") except: print("Input error!")
标签:__name__ poi ber tle 使用方法 less except ror abs
原文地址:http://blog.51cto.com/9473774/2061673