Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accepting inputs str vs int
#3
Thanks for your help @deanhystad . I had come across the try/except set but I'd assumed as it hadn't been covered in the course I'm working through that I wouldn't need it. I've posted my final, working function below and marked solved.
def move_accept(z):
    while True:
        try:
            print("Enter the coordinates: ")
            coords_ = input()
            coords_ = coords_.split()
            if not ((0 < int(coords_[0]) <= 3) and (0 < int(coords_[1]) <= 3)):
                print("Coordinates should be from 1 to 3!")
            elif not valid_play_finder(int(coords_[0]), int(coords_[1]), z):
                print("This cell is occupied! Choose another one!")
            else:
                return coords_
        except ValueError:
            print("You should enter numbers!")
Reply


Messages In This Thread
Accepting inputs str vs int - by lbtdne - May-13-2020, 06:14 PM
RE: Accepting inputs str vs int - by deanhystad - May-13-2020, 07:41 PM
RE: Accepting inputs str vs int - by lbtdne - May-14-2020, 01:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with accepting multiple string inputs Ryan_Todd 5 2,945 Jan-22-2020, 06:12 PM
Last Post: buran
  signal.itimer() not accepting keyword arguments Skaperen 2 2,245 Dec-19-2019, 12:14 AM
Last Post: Skaperen
  Accepting strings as arguments when slicing a string? (Ziyad Yehia on Udemy) Drone4four 4 3,792 Aug-23-2019, 07:59 PM
Last Post: Drone4four
  Sqlalchemy accepting ISO 8601 KirkmanJ 0 3,582 Jul-27-2018, 01:52 PM
Last Post: KirkmanJ
  MySQL not accepting utf8mb4. Warning 3719 jonesin1974 0 4,770 Jun-21-2018, 03:09 AM
Last Post: jonesin1974
  if loop is not accepting && A_Embedded 2 2,750 Apr-22-2018, 02:24 PM
Last Post: A_Embedded

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020