MajorMEllow
2012-10-12 16:40:43 UTC
I am stuck, if you can help i would really appreciate it.
So i have been given a task to make a funciton that return a string as hidden
for example:
>>> get_view ('apple'):
'^^^^^'
>>> get_view ('apple-banana')
'^^^^^-^^^^^^'
So we are only trying to hide lower-case letters and nothing else...
My func so far is:
def get_view (puzzle):
''' (str) -> str
>>>get_view ('apple')
'^^^^^'
>>>get_view ('apple-banana')
'^^^^^-^^^^^^'
'''
return len(puzzle) * HIDDEN <-- But it hides EVERYTHING...
Also, in the next function i have 3 strings...
def update_view (puzzle, view, guessed_letter):
''' (str, str, str) -> str
Return the view of the puzzle with each occurrence of the letter in
the puzzle revealed.
>>>update_view ('apple', '^^^^^', 'a')
'a^^^^'
>>>update_view ('apple', '^^^^^', 'p')
'^pp^^'
'''
view == puzzle
for i in puzzle[0:]:
if (guessed_letter in puzzle):
return guessed_letter + view[0+1:] <-- But it only reveals the first letter...i want a condition that would match the placement...
THANKS FOR ALL YOUR HELP:)