CompSci Blogs

August 2023 to June 2024

View the Project on GitHub IshanCornick/new_student

2 October 2023

Worlde

#!/bin/python3

#Check instructions to learn how to play!

import random
with open("word_list.txt",'r') as f:
  word_list = [line.rstrip('\n') for line in f] 

print ("Check instructions to learn how to play!")
answer = random.choice(word_list)
# 5 letter words
i=0
while i<6:
  q = input("Enter your 5 letter word")
  if len(q) != 5:
    print ("5 letters only")
    continue
  if q not in word_list:
    print ("NOT VALID WORD")
    continue
# Is the word in there?  
  print ("-----")
  for j in q:
    if q.find(j) == answer.find(j):
      print ("🟢" + j)
    elif j in answer:
      print ("🟡" + j)
    else:
      print ("âš«" + j)
    
  if q == answer:
    print ("You win!🎉🎉🎉")
    break
# is the letter in position
  
  i+=1  
  if i==6:
    print ("The answer is:")
    print (answer)
Check instructions to learn how to play!
5 letters only
-----
âš«c
âš«r
âš«e
âš«a
âš«m
-----
âš«c
âš«r
âš«e
âš«a
âš«m
-----
âš«a
âš«d
🟢i
âš«e
âš«u
5 letters only
NOT VALID WORD
-----
âš«p
âš«e
🟡n
🟡i
âš«s
-----
âš«p
âš«e
🟡n
🟡i
âš«s
5 letters only
-----
âš«b
âš«r
🟢i
âš«d
âš«e
The answer is:
hying
#!/bin/python3

#Check instructions to learn how to play!

import random
with open("word_list.txt",'r') as f:
  word_list = [line.rstrip('\n') for line in f] 

print ("Check instructions to learn how to play!")
answer = random.choice(word_list)
# 5 letter words
i=0
while i<6:
  q = input("Enter your 5 letter word")
  if len(q) != 5:
    print ("5 letters only")
    continue
  if q not in word_list:
    print ("NOT VALID WORD")
    continue
# Is the word in there?  
  print ("-----")
  for j in q:
    if q.find(j) == answer.find(j):
      print ("🟢" + j)
    elif j in answer:
      print ("🟡" + j)
    else:
      print ("âš«" + j)
    
  if q == answer:
    print ("You win!🎉🎉🎉")
    break
# is the letter in position
  
  i+=1  
  if i==6:
    print ("The answer is:")
    print (answer)
Check instructions to learn how to play!
5 letters only
-----
âš«c
âš«r
âš«e
âš«a
âš«m
-----
âš«c
âš«r
âš«e
âš«a
âš«m
-----
âš«a
âš«d
🟢i
âš«e
âš«u
5 letters only
NOT VALID WORD
-----
âš«p
âš«e
🟡n
🟡i
âš«s
-----
âš«p
âš«e
🟡n
🟡i
âš«s
5 letters only
-----
âš«b
âš«r
🟢i
âš«d
âš«e
The answer is:
hying