
-----------------------------------
Panphobia
Thu Nov 15, 2012 8:07 pm

Python running error
-----------------------------------
I started learning python, and as practise I started re-doing all the questions for dwite in python, I ran into a problem with this question http://dwite.org/questions/arablish_numbers.html, here is my code that should work [code]import sys

sys.stdin = open('DATA1.txt')
sys.stdout = open('OUT1.txt', 'w')

for y in range(0,5):
    temp = ""
    newString=""
    size=[]
    size = input().split()
    for i in range(0,len(size)):
        temp = size[i]
        if temp.isdigit():
            newString = temp +newString
        else:
            for x in range(0,len(temp)):
                newString = temp[x]+newString
    newString+=" "
    print(newString.strip())
                [/code]
here is my data1.txt contents [code]tsetnoc siht ni snoitseuq 5 era ereht
ABC 123 abc123
aosdfi12345akjufd
mama hey mama 123 easy as bca i say
amam lol tahw pu ym reggin[/code]
and here is the error
[code]Traceback (most recent call last):
  File "C:\Users\DANIEL\Desktop\Python\de.vogella.python.first1\src\FirstMod.py", line 15, in 
    size = input().split()
  File "C:\Users\DANIEL\Desktop\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydev_sitecustomize\sitecustomize.py", line 210, in input
    return eval(raw_input(prompt))
  File "", line 1
    tsetnoc siht ni snoitseuq 5 era ereht
               ^
SyntaxError: invalid syntax[/code]

-----------------------------------
btiffin
Fri Nov 16, 2012 1:58 am

Re: Python running error
-----------------------------------
Yeah, see http://docs.python.org/2/library/functions.html#input then see http://docs.python.org/2/library/functions.html#raw_input which skips the evaluator.

Cheers

-----------------------------------
Panphobia
Fri Nov 16, 2012 1:20 pm

RE:Python running error
-----------------------------------
got it, Thanks :D
