Skip to content

Instantly share code, notes, and snippets.

@simonbrowndotje
Created July 3, 2014 15:35
Show Gist options
  • Save simonbrowndotje/989240fbc115e231297b to your computer and use it in GitHub Desktop.
Save simonbrowndotje/989240fbc115e231297b to your computer and use it in GitHub Desktop.
A short Python 3 program that I used with year 6 at St Martin's School in Jersey
import random
def removeRandomLetterFrom(word):
lengthOfWord = len(word)
randomNumber = random.randint(0, lengthOfWord-1)
letterToRemove = word[randomNumber]
newWord = ""
for letter in word:
if letter == letterToRemove:
newWord += "_"
else:
newWord += letter
return newWord
words = [
"second",
"following",
"together",
"without",
"outside",
"suddenly",
"different",
"coming",
"between",
"across"
]
correctSpellings = 0
for word in words:
print("How do you spell", removeRandomLetterFrom(word), "?")
spellingTry = input()
if spellingTry == word:
print(" - Well done, that's correct!")
correctSpellings += 1
else:
print(" - Sorry, that's not correct.")
print("You got", correctSpellings, "out of", len(words), "correct")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment