On 9/13/2010 8:19 AM, Roelof Wobben wrote:
Hello,

I have this string called test with the contents of 'het is een wonder \\TIS'

Now I want to get rid of the \\ so I do this : test2 = test.replace ('\\', '')
And I get at the python prompt this answer : 'het is een wonder TIS'
So that's right.

Now I try the same in a IDE with this programm :

woorden =[]
letter_counts = {}
file = open ('alice_in_wonderland.txt', 'r')
for line in file:
     line2 = line.replace ("\\","")
     line3 = line2.lower()
     woorden = line3.split()
     for letter in woorden:
         letter_counts[letter] = letter_counts.get (letter, 0) + 1
letter_items = letter_counts.items()
letter_items.sort()
print letter_items

But now Im gettting this output :

[('"\'tis', 1),

Why does the \ stays here. It should have gone as the test in the python prompt 
says.
I ran your program against a 1 line file containing 'het is een wonder \\TIS' The result I get is [('een', 1), ('het', 1), ('is', 1), ('tis', 1), ('wonder', 1)]

Dunno why you are getting a different result.

Here is where using the debugger and going step by step can help. I have no experience with the IDLE debugger. Perhaps others can offer advice on that.

--
Bob Gailer
919-636-4239
Chapel Hill NC

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to