View Full Version : Raptor and reversing a sting???
Apr 7, 2012, 05:47 PM
I have to submit code for my class where I design a program that prompts the user to enter a string and then displays the string contents backward. For instance, if the user entered "gravity" the program should display "ytivarg." I have the python code done. To reverse the word I used, word = raw_input, then print word [::-1]. But I can not figure out how to make it work in Raptor. I don't know the language to use to make it reverse a string. Any help would be appreciated as this assignment is due tonight! Thanks!!
Apr 7, 2012, 06:54 PM
First off, Python basically 'cheats' at this so just because you can do it in Python doesn't mean you've mastered the concept of reversing a string. Most languages don't have a built in function that will do it without thinking about it.
Secondly, what is 'Raptor' all I can find is some kind of flow chart language which seems like it can't be right.
EDIT: Actually this probably is the 'Raptor' you're referring to. You need to think of what is actually required to reverse a string. One way would be to use a concept of a stack or recursion. Another way would be to use built in string language constructs that prepend strings if available.