This commit is contained in:
Andros Fenollosa 2016-11-27 10:23:07 +01:00
parent 2b7ba61912
commit 873a3301ca

View File

@ -64,9 +64,13 @@ def best_letter(word_resolve):
sorted_letters = sorted( sorted_letters = sorted(
letters.items(), key=operator.itemgetter(1), reverse=True letters.items(), key=operator.itemgetter(1), reverse=True
) )
# Best letter # Best letter
return sorted_letters[0][0] if len(sorted_letters) > 0:
return sorted_letters[0][0]
else:
end = True
print('No more possibilities')
return None
# End Functions # End Functions
@ -98,34 +102,34 @@ print('')
while play: while play:
# Get best letter # Get best letter
best_option = best_letter(word_resolve) best_option = best_letter(word_resolve)
# The guard not to give it back if best_option:
letters_used.append(best_option) # The guard not to give it back
print_words() letters_used.append(best_option)
# Print best letter print_words()
print('Test with the letter> {letter}'.format( # Print best letter
letter=best_option.upper() print('Test with the letter> {letter}'.format(
)) letter=best_option.upper()
# Save successes ))
print('') # Save successes
question_success = raw_input('I successful? (yes o no): ').lower()
clear()
if question_success == 'no':
clear()
print('') print('')
print('Ups!') question_success = raw_input('I successful? (yes o no): ').lower()
elif question_success == 'yes':
print('')
print_words(True)
good_pos = raw_input('Tell me that positions (Example> 2 4 7): ').split(' ')
clear() clear()
for pos in good_pos: if question_success == 'no':
word_resolve[int(pos) - 1] = best_option clear()
print('')
print('Ups!')
elif question_success == 'yes':
print('')
print_words(True)
good_pos = raw_input('Tell me that positions (Example> 2 4 7): ').split(' ')
clear()
for pos in good_pos:
word_resolve[int(pos) - 1] = best_option
# Game over # Game over
end = True end = False
for letter in word_resolve: if not '_' in word_resolve:
if letter != '_': end = True
end = False
if end: if end:
play = False play = False
print('Game over :)') print('Game over :)')