Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Silverbird0000

macrumors 6502a
Original poster
Sep 19, 2006
582
22
Fort Myers, FL
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!!
 

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.