Skip to content

Commit 192d379

Browse files
authored
Update Scrabble.py
1 parent 3144d84 commit 192d379

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

BasicPythonScripts/Scrabble/Scrabble.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
# Points assigned to each letter of the alphabet
33
POINTS = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]
44
score1 = score2 = 0
5+
# Gives a random letter to the user to start with
56
print("Enter a word starting with the letter "+ chr(r.randint(65, 90)))
67
# Get input words from both players
78
word1 = input("Player 1:")
89
word2 = input("Player 2:")
910

1011
# Calculating the score of Player1
12+
# Points given to each letter are irrespective of the case
1113
for i in word1:
1214
if word1.isupper():
13-
score1 += POINTS[ord(i) - ord('A')]
15+
score1 += POINTS[ord(i) - ord('A')] #ord returns the ASCII value of the letter
1416
elif word1.islower():
1517
score1 += POINTS[ord(i) - ord('a')]
1618
#Claculating the score of Player2
1719
for i in word2:
1820
if word2.isupper():
19-
score2 += POINTS[ord(i) - ord('A')]
21+
score2 += POINTS[ord(i) - ord('A')] #ord returns the ASCII value of the letter
2022
elif word2.islower():
2123
score2 += POINTS[ord(i) - ord('a')]
2224

0 commit comments

Comments
 (0)