This repository has been archived by the owner on Oct 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCollabProj.txt
98 lines (79 loc) · 3.38 KB
/
CollabProj.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#APCSP Create Task - Carreon,Matthew & Magdangal,Vinpatrik
import random
#Selection of words, feel free to change whenever
wordList = ["short", "test", "words"]
#Taken from geeksforgeeks.org
def wordSplit(word):
return [char for char in word]
#####################################################################################
# This section splits a randomly selected word and creates the blank spaces #
#####################################################################################
#Adds each character in the selected word into a list
wordListSelection = random.choice(wordList)
selectedWord = (wordSplit(wordListSelection))
print("DEV TEST: The correct answer for selectedWord (list) is:" + str(selectedWord) + "\n")
#shownList is the characters input by the user
shownList = []
for x in range(0, len(selectedWord)):
shownList.append("_")
print("You used the letters: " + str(shownList))
######################################################################################
# This is where the guessing part starts #
######################################################################################
guessCounter = 0
guessedLetters = []
youWin = bool(False)
underscoreCount = len(shownList)
inSession = True
print("underscoreCount is " + string(underscoreCount)
#Fail safe for the youWin condition (fails on "test")
#runs until the number of guesses reaches
while youWin == False:
#while (inSession == True) and not((underscoreCount == 0)):
guess = input("Please guess a letter: ")
guessedLetters.append(guess)
guessCounter += 1
print(guessedLetters)
for num in range(0,len(shownList)):
if guess == selectedWord[num]:
del shownList[num]
shownList.insert(num, guess)
#if there is an underscore, it keeps going
for num in range(0,len(shownList)):
if "_" == shownList[num]:
print("DEV IF: selectedWord[num] is " + str(selectedWord[num]))
print("There is an underscore.")
youWin = False
else:
print("DEV ELSE: selectedWord[num] is " + str(selectedWord[num]))
print("There is no underscore.")
youWin = True
print(shownList)
print("You won! Yay!")
######################################################################################
# Visuals for the stickman itself based off guesses # # -M #
######################################################################################
'''
print(" | ")
print(" | ")
if (guessCounter <= 1):
print(" () ")
if (guessCounter <= 2):
print(" /|\ ")
if (guessCounter <= 3):
if (guessCounter <= 4):
if (guessCounter <= 5):
if (guessCounter <= 6):
print(" /\ ")
print(" | ")
print(" | ")
print(" () ")
print(" /|\ ")
print(" /\ ")
'''
######################################################################################
# CHANGELOG # # #
######################################################################################
"""
4/28: Changed if else selectedWord to shownList (Fixed the loop)- M
"""