So I came across this Scrabble Game question where one types in a word they should calculate the score based on the words they typed in. So after more than a year I haven’t really touch coding, I decided to give this a try so this is what I got.
#Scrabble Game
letters=[]
score=0
count=0#Defining score feature
def checkScores(x):
return {
‘a’: 1,
‘b’: 3,
‘c’: 3,
‘d’: 1,
‘e’: 2,
‘f’: 2,
‘g’: 4,
‘h’: 1,
‘i’: 4,
‘j’: 5,
‘k’: 8,
‘l’: 3,
‘m’: 1,
‘n’: 1,
‘o’: 1,
‘p’: 10,
‘q’: 3,
‘r’: 1,
‘s’: 1,
‘t’: 1,
‘u’: 1,
‘v’: 4,
‘w’: 4,
‘x’: 4,
‘y’: 8,
‘z’: 10
}.get(x.lower(), 0)print(‘Scrabble Game’)
word = input(‘Enter a word: ‘)
letters = [x.strip() for x in word]print(‘*****************************’)
print(‘* Letter * Score *’)
print(‘*****************************’)#Loop to display letters and calculate score for each letters
for count in range(len(letters)):
checkPoint = int(checkScores(letters[count]))
if checkPoint != 0 :
print(‘* ‘,letters[count],’ * ‘,checkPoint,’ *’)
print(‘*****************************’)
if score ==0 :
score = checkPoint
else:
score = score +checkPointprint (‘Total Score :’,score)
What I noticed about Python is that there’s not really a switch case thing but using a dictionary instead which pretty much works the same. Initially I was using if else statement, but it was quite messy. Never the less, it’s the best I could think of at the moment. Might try something else in the future.
Hello Alex,
I want to desactivTe the fitbit bit function from the watch gps. First time I activated the watch , I was able to see the health menu in se teacker and now eveytime I log in , I can’t see it anymore. I want to display the date instead of that person standing i the watch display , not sure how to disactivate it
Can you help
To disable the pedometer function send in this SMS.
pw,123456,pedo,0#