Python Exercise Example 79
**Problem:** Sort strings.
**Analysis:** None.
Example (Python 2.0+)
#!/usr/bin/python
-- coding: UTF-8 --
if
name
==
'
main
'
:
str1
=
raw_input
(
'
input string:
\n
'
)
str2
=
raw_input
(
'
input string:
\n
'
)
str3
=
raw_input
(
'
input string:
\n
'
)
str1
,
str2
,
str3
if
str1
str2
:
str1
,
str2
=
str2
,
str1
if
str1
str3
:
str1
,
str3
=
str3
,
str1
if
str2
str3
:
str2
,
str3
=
str3
,
str2
'
after being sorted.
'
str1
,
str2
,
str3
The output of the above example is:
input string:
abcde
input string:
efdis
input string:
adk
abcde efdis adk
after being sorted.
abcde adk efdis
Python 100 Examples