Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Exercise Example 72

Python Exercise Example 72

Python 100 Examples Python 100 Examples

**Problem:** Create a linked list.

**Analysis:** None.

Example (Python 2.0+)

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

The output of the above example is:


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]

Python 100 Examples Python 100 Examples