Start New Discussion within our Software Development Community

Hi i am new at python,i am getting problem in the above code,the problem reads as follows:


Having several accounts on several servers, one has to remember many passwords. You can imagine a situation where someone forgets one of them and he or she only remembers that it consisted of certain words and digit combinations. For example, one might remember that the password likely consisted of words x, y and z, and had digits between the words. That is: <word><digit><word><digit><word>. There might also be cases where there are multiple possible words, but the user is sure he or she only used 1 of them in the password.

Your task is to write a program which will generate all possible passwords from a given dictionary and set of rules. For the example given above the dictionary contains three words: x, y, z, and the rule is given as #0#0# which stands for <word><digit><word><digit><word>.
Input
First line contains a number of words in the dictionary (n). The words themselves are given in n consecutive lines. The next line contains the number of rules (m). Similarly consecutive m lines contain rules. Each rule consists of characters `#' and `0' given in arbitrary order. The character `#' stands for a word from the dictionary, whilst the character `0' stands for a digit.

Input data may contain many sets of dictionaries with multiple rules attached to them.
Output
For each set of dictionary and rules you should output two hyphens followed by a linebreak and all matching passwords given in consecutive lines. Passwords should first be output in rule order. That is, all passwords for rule 1 should be output first, followed by passwords for rule 2 etc. Within each set of passwords, the passwords should be ordered. 2 rules apply: digits must be numerically ascending; words should be in the order they were listed in the dictionary.

Assumptions: The number of words in the dictionary is greater than 0 and smaller or equal to 100 (0 < n ≤ 100). Length of the word is greater than 0 and smaller than 256. A word may contain characters `A'..`Z',`a'..`z',`0'..`9'. The number of rules is smaller than 1000, and a rule is shorter that 256 characters. The character `0' may occur in the rule no more than 7 times, but it has to occur at least once. The character `#' is not mandatory meaning that rules containing no '#' can occur.
Sample Input

2
root
2super
1
#0
1
admin
1
#0#
2
a
b
2
##0
0


Sample Output

--
root0
root1
root2
root3
root4
root5
root6
root7
root8
root9
2super0
2super1
2super2
2super3
2super4
2super5
2super6
2super7
2super8
2super9
--
admin0admin
admin1admin
admin2admin
admin3admin
admin4admin
admin5admin
admin6admin
admin7admin
admin8admin
admin9admin
--
aa0
aa1
aa2
aa3
aa4
aa5
aa6
aa7
aa8
aa9
ab0
ab1
ab2
ab3
ab4
ab5
ab6
ab7
ab8
ab9
ba0
ba1
ba2
ba3
ba4
ba5
ba6
ba7
ba8
ba9
bb0
bb1
bb2
bb3
bb4
bb5
bb6
bb7
bb8
bb9
0
1
2
3
4
5
6
7
8
9

A code snippet is working code! Do not paste your homework problems here!

n=raw_input()
while(n!=''):
    print '--'
    n=int(n)
    d=[]
    i=0
    lists=[]
    f=''
    while(i<n):
        m=raw_input()
        d+=[m]
	i+=1
    i=0
    t=int(raw_input())
    while(i<t):
	m=raw_input()
	lists+=[m]
	i+=1
    r=0
    me=[]
    k=0
    while(k<len(lists)):
	for i in d:
		for r in range(10):
			for j in lists[k]:
				if(j=='#'):
					f+=i
				else:
					f+=str(r)
			me+=[f]
			f=''
		for i in me:
			print i
		me=[]
	k+=1
    n=raw_input()