Advertisement
MGakowski

Mask Sorter.py

Nov 17th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. n = 0
  2. score = 0
  3. count = 0
  4.  
  5. f = str(raw_input("Filename? "))
  6. file = open(f + ".txt", "r")
  7. linecount = int(len(file.readlines()))
  8. file = open("mask.txt", "r")  # Have to open again to go to beginning of file.
  9.  
  10. for y in range(linecount):  # Repeat for amount of lines, NOTE: End of file must have blank line(linebreak is a char)
  11.     mask = file.readline()
  12.     chars = len(mask)-1
  13.     # Get number of chars in line and repeat adding until done then next line
  14.     while n != int(chars):
  15.         if str(mask[count]) == "l":
  16.             score += 26
  17.             count += 1
  18.             n += 1
  19.         if str(mask[count]) == "u":
  20.             score += 26
  21.             count += 1
  22.             n += 1
  23.         if str(mask[count]) == "d":
  24.             score += 10
  25.             count += 1
  26.             n += 1
  27.         if str(mask[count]) == "s":
  28.             score += 33
  29.             count += 1
  30.             n += 1
  31.         if str(mask[count]) == "a":
  32.             score += 95
  33.             count += 1
  34.             n += 1
  35.         if str(mask[count]) == "h":
  36.             score += 16
  37.             count += 1
  38.             n += 1
  39.     else:
  40.         print score
  41.         count = 0
  42.         score = 0
  43.         n = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement