Create tools_reverse.py
Browse files- tools_reverse.py +10 -0
 
    	
        tools_reverse.py
    ADDED
    
    | 
         @@ -0,0 +1,10 @@ 
     | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
| 
         | 
|
| 1 | 
         
            +
            import re
         
     | 
| 2 | 
         
            +
             
     | 
| 3 | 
         
            +
            def flip_hidden(question):
         
     | 
| 4 | 
         
            +
                # Reverse only the text before '.rewsna' if present
         
     | 
| 5 | 
         
            +
                match = re.search(r'^(.*)\.rewsna', question)
         
     | 
| 6 | 
         
            +
                if match:
         
     | 
| 7 | 
         
            +
                    to_flip = match.group(1)
         
     | 
| 8 | 
         
            +
                    return to_flip[::-1].strip()
         
     | 
| 9 | 
         
            +
                # Fallback: reverse the whole string
         
     | 
| 10 | 
         
            +
                return question[::-1] 
         
     |