5
votes
4answers
550 views

Change upper or lowercase vowels to [0,1,2,3,4] respectively and leave the rest the same

The objective was the following to be solved in Python: Given a string, def a function that returns another string with the vowels (upper o lowercase) replaced by 0,1,2,3,4 respectively. ...
5
votes
2answers
434 views

Word frequency generator in Python

Please critique my word frequency generator. I am a beginner programmer so any criticism are welcome. Original Code: http://pastebin.com/rSRfbnCt Here is my revised code after the feedback: import ...
5
votes
1answer
536 views

Memory issues with Find Strings Problem on InterviewStreet

Here is the code I wrote for the problem at http://www.interviewstreet.com/recruit/challenges/solve/view/4e1491425cf10/4efa210eb70ac where we need to to print the substring at a particular index from ...
5
votes
2answers
192 views

Is there better ways to traverse a multidimensional structure and apply strip() to all strings?

I'm trying to apply string.strip() to all the leafs that are strings in a multidimensional collection, but my python is a bit rusty (to say the least). The following is the best I've come up with, but ...
4
votes
1answer
67 views

Nicely tabulate a list of strings for printing

I have a list of strings of variable lengths, and I want to pretty-print them so they are lining up in columns. I have the following code, which works as I want it to currently, but I feel it is a ...
3
votes
4answers
146 views

Can this string parse be improved?

My data is in this format: 龍舟 龙舟 [long2 zhou1] /dragon boat/imperial boat/\n And I want to return: ('龍舟', '龙舟', 'long2 zhou1', '/dragon boat/imperial boat/') In C I could do this in one line with ...
3
votes
1answer
152 views

Substitution of different occurrences of a string with changing patterns

I need to parse an invalid JSON string in which I find many repetitions of the same key, like the following snippet: [...] "term" : {"Entry" : "value1", [.. other data ..]}, "term" : {"Entry" : ...
2
votes
3answers
122 views

XML-tag function

I'm an experienced programmer, but just a beginner in Python, and would like some input on a small function that's working but which I'm not very happy with. It's used to produce XML tags (strings). ...
2
votes
1answer
112 views

Python 3: Finding common patterns in pairs of strings

I have written a piece of code that finds common patterns in two strings. These patterns have to be in the same order, so for example "I am a person" and "A person I am" would only match "person". The ...
2
votes
1answer
178 views

Get metadata from an Icecast radio stream

I am new to Python and not very familiar with advanced Python data structures. I have written a function to receive data from a socket in Python and perform string manipulations on it. The basic ...
2
votes
3answers
39 views

Flexible multiple string comparision to determine variable value

I've a web form that allows users to create clusters of three sizes: small, medium and large. The form is sending a string of small, medium or large to a message queue, were job dispatcher determines ...