3 Replies - 616 Views - Last Post: 16 November 2010 - 06:44 AM Rate Topic: -----

#1 Megakeemo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-November 08

What Type of Input Must This Program Take?

Posted 15 November 2010 - 09:14 AM

The function should take a board, and x and y coordinates and returns the contents on the board at the location specified by the coordinates.

Here's the function:

def get_cell(board,x,y):
    pass


And here's the function that it should be incorporating:

def make_board():
    """Creates a brand new, blank board data structure. Returns the board data structure
    """
    board = []
    for i in range(8):
        board.append([' '] * 8)
    return board


What I basically want to do is insert an element somewhere in the list 'board' using the function get_cell().
However, how exactly to put that list in the Python Shell is what's puzzling me.

Is This A Good Question/Topic? 0
  • +

Replies To: What Type of Input Must This Program Take?

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,517
  • Joined: 23-August 08

Re: What Type of Input Must This Program Take?

Posted 15 November 2010 - 12:20 PM

Firstly, I would suggest that using a name like get_cell is wrong for a method that is looking to INSERT a cell. put_cell or set_cell would be more appropriate.

Second, are you looking for someone to provide you with the implementation of this method? I'm a bit confused where you mention the Python shell whether you mean how the USER would input the data or not.
Was This Post Helpful? 0
  • +
  • -

#3 Megakeemo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-November 08

Re: What Type of Input Must This Program Take?

Posted 15 November 2010 - 07:19 PM

I'm not asking for code, I'm asking how one(the user) would input the data in the shell.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,517
  • Joined: 23-August 08

Re: What Type of Input Must This Program Take?

Posted 16 November 2010 - 06:44 AM

I'd do something like this:
value=raw_input("Enter coordinates (x,y): ");

then split the input on a , and validate it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1