Reverse a string
October 9th, 2006 toydi
python provides a -c option to accept and run a script line. To reverse a string like this one: “toydi deified idiot”. echo ‘toydi deified idiot’ | python -c “print raw_input()[::-1]” echo prints the string to stdout. python run the script line. raw_input() read from stdin (to read from pipe and return the string). [::-1] [...]
Posted in python, rev | Hits: 50501 | 10 Comments »






