Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. """
  5. Content of test.txt
  6. STY: 6
  7. TÅL: 11
  8. RÖR: 20
  9. PER: 9
  10. PSY: 14
  11. VIL: 11
  12. BIL: 7
  13. SYN: 17
  14. HÖR: 7
  15. """
  16.  
  17.  
  18. def get_value_str():
  19.     f = file('test.txt', 'r')
  20.     the_string = f.readlines()
  21.     f.close()
  22.     for word in the_string:
  23.         if "STY" in word:
  24.             the_line = str(word)
  25.             return the_line[5:]
  26.  
  27.  
  28. def get_value_con():
  29.     f = file('test.txt', 'r')
  30.     the_string = f.readlines()
  31.     f.close()
  32.     for word in the_string:
  33.         if word.find('TÅL') != -1:
  34.         # if "TÅL" in word:
  35.             the_line = str(word)
  36.             return the_line[5:]
  37.         #else:
  38.             #return 0
  39.  
  40.  
  41. def main():
  42.     strength = int(get_value_str())
  43.     print strength
  44.     constitution = int(get_value_con())
  45.     print constitution
  46.  
  47. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement