Python Exercise Example 82
**Problem:** Convert octal to decimal
**Analysis:** None.
Example (Python 2.0+)
#!/usr/bin/python
-- coding: UTF-8 --
if
name
==
'
main
'
:
n
=
0
p
=
raw_input
(
'
input a octal number:
\n
'
)
for
i
in
range
(
len
(
p
)
)
:
n
=
n
8
ord
(
p
[
i
]
)
ord
(
'
0
'
)
n
The output of the above example is:
input a octal number:
122
82
Python 100 Examples