[Tutor] python help

Natasha Menon natmenon at yahoo.com
Wed Feb 8 18:19:12 CET 2006


Hi,
   
  I have a few doubts in python programming. C if any of u can help me out. 
   
  1. 
  In a file called string_stuff.py i have to write a function called frequencies that takes a string as a parameter and returns a dictionary where the keys are the characters from the string and each value is an integer indicating the number of times the key appeared in the string. 
   
  2.
  Similary in the same file string_stuff.py, have to write a function called locations that takes a string as a parameter and returns a dictionary where the keys are the characters from the string and each value is a list indicating the indices in the string at which the key appears, sorted in increasing order.
   
  3.
  In the same file string_stuff.py, write a function called concordance that takes an open file as a parameter and returns a dictionary where the keys are the strings from the file and each value is a list of line numbers of the lines in which the key appeared, sorted in increasing order. Start counting at 0. Each line number should appear at most once in a list, even if a word appears twice on a line. You may assume that the input consists only of alphabetic letters (a-z, A-Z) and whitespace. 
   
   
  Id really appreciate if you could help me on these small question. I am tryin to learn to program in python.
   
  Thanks,
  Natasha

		
---------------------------------
Brings words and photos together (easily) with
 PhotoMail  - it's free and works with Yahoo! Mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060208/c5190e23/attachment.htm 


More information about the Tutor mailing list