Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. def kysy_koordinaatit(leveys, korkeus):
  2.     while True:
  3.         try:
  4.             syote = input("Anna kooridnaatit muodossa x,y, tai lopeta peli painamalla q: ")
  5.             if syote == "q":
  6.                 return None, None
  7.             if syote.count(",") > 1:
  8.                 print("Lue ohjeet huolellisemmin!")
  9.                 continue
  10.             else:
  11.                 x, y = syote.split(',')
  12.                 x, y = int(x), int(y)
  13.         except ValueError:
  14.             print("Virhe: anna koordinaatit kokonaislukuina!")
  15.             continue
  16.         else:
  17.             if tarkista_koordinaatit == False:
  18.                 print("Koordinaatit ovat ruudukon ulkopuolella.")
  19.             else:
  20.                 return x, y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement