Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import time
- points = 0
- rounds = int(input("How many rounds of scrabble?"))
- lengths = []
- new = open('words.txt', 'r')
- word_list = new.readlines()
- new.close()
- letters = []
- common_letters = []
- for word in word_list:
- lengths.append(len(word))
- for letter in word:
- letters.append(letter)
- for x in range(0, len(letters)):
- if letters.count(letters[x])>1 and letters[x] not in common_letters:
- common_letters.append(letters[x])
- common_letters.remove('\n')
- for r in range(1, rounds+1):
- letters_available = ''
- for n in range(0, max(lengths)):
- choice = random.choice(common_letters)
- while choice in letters_available:
- choice = random.choice(common_letters)
- letters_available += choice
- if n == max(lengths)-1:
- pass
- else:
- letters_available += ', '
- printable = letters_available
- letters_available = letters_available.replace(', ', '')
- print("Round {}:\n".format(r))
- guess = input("What words can you make from {} ? ".format(printable))
- guess = guess.replace(' ', '')
- correct = 0
- if guess+'\n' not in word_list:
- print(guess,"is not a word!")
- else:
- for letter in letters_available:
- if letter in guess:
- correct += 1
- if correct == len(guess):
- print("Correct! You get {} points!".format(len(guess)))
- points += len(guess)
- else:
- print("Incorrect! You get {} points since you got {} letters right!".format(correct, correct))
- print("You finished {} rounds with {} points!".format(rounds, points))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement