打印

Python 练习实例73

[复制链接]
181|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
cooldog123pp|  楼主 | 2023-5-27 11:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
题目:反向输出一个链表。
程序分析:无。
#!/usr/bin/python
# -*- coding: UTF-8 -*-

if __name__ == '__main__':
    ptr = []
    for i in range(5):
        num = int(raw_input('please input a number:\n'))
        ptr.append(num)
    print ptr
    ptr.reverse()
    print ptr
以上实例输出结果为:
please input a number:
6
please input a number:
5
please input a number:
3
please input a number:
4
please input a number:
8
[6, 5, 3, 4, 8]
[8, 4, 3, 5, 6]







使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1592

主题

5838

帖子

29

粉丝