Python编程之创建链表

问题描述:创建一个链表。

源代码:


#!/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

输出结果如下:

please input a number:
3
please input a number:
5
please input a number:
7
please input a number:
8
please input a number:
2
[3, 5, 7, 8, 2]



please input a number:
1
please input a number:
2
please input a number:
3
please input a number:
4
please input a number:
5
[1, 2, 3, 4, 5]

 

你可能感兴趣的:(Python学习馆,Python学习馆)