题解 | #提取不重复的整数#

提取不重复的整数

https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1

from csv import list_dialects
import sys

def newer(str_num):
    # 遍历去重并且反转
    list_newer = []
    list_num = list(str_num)
    list_num.reverse()
    for c in list_num:
        if c not in list_newer:
            list_newer.append(c)  
    # list转字符串
    str_newer = ''.join(list_newer)
    # 字符串转int
    int_newer = int(str_newer)
    return int_newer


if __name__ == '__main__':
    str_num = sys.stdin.readline().strip()
    result = newer(str_num)
    print(result)

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务