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.
Roelof
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor