## I have to get rid of q but don't know how

This is the place for queries that don't fit in any of the other categories.

### I have to get rid of q but don't know how

Code: Select all
`import random# Making the board:def makeBoard(n):    board = []    for count in range(n):        board.append([q] * n)    return board# Defining fillsquare:def fillSquare(board, char):    X = random.randint(0 ,n-1)    Y = random.randint(0 ,n-1)    if q in board[X][Y]:        board[X][Y] = Char# Drawing the game board:def drawBoard(n, board):    Top = "+-------" * n    Side = "|       " * n    Mid = ""    for X in range(n-1):        for Y in range(n-1):            for count in range(n):                for count1 in range(n):                    Mid += ("|   " + board[X + count][Y + count1] + "   ")                print(Top + "+")                print(Side + "|")                print(Mid + "|")                Mid = ""                print(Side + "|")            Mid = ""            print(Top + "+")            break        breakq = ' 'n = 7board = makeBoard(n)# Filling the squares with characters:Characters = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']for count1 in range(2):    while q in board[count1]:        Char = "A"        fillSquare(board,Char)for count in range(0, n-1):    while q in board[count]:        Char = " "        fillSquare(board,Char)drawBoard(n, board)# Getting a user input direction:def getDirection():    direction = ""    while direction != "up" or direction != "down" or direction != "left" or direction != "right":        direction = input("Please enter a direction(up,down,left,right): ")        if direction == "up" or direction == "down" or direction == "left" or direction == "right":            break    return directiondirection = getDirection()# Getting a tile on the board:def getSquare(n):    tile_number = 10000000000000000    while tile_number <= n*n or tile_number > 0:        tile_number = int(input("Enter your tile number: "))        if tile_number <= n*n:            break        else:            tile_number = int(input("Enter your tile number: "))    square=[tile_number]    return squaresquare = getSquare(n)#print(square)# Determining if the square selected is occupied:pos = Chardef isEmpty(pos,board):    square = getSquare(n)    if pos == q :        print("Square", square, "is empty.")    if pos == Characters:        print("Square", square, "is occupied.")    return posTile = isEmpty(pos,board)print(Tile)# Getting the player's move:def getMove(direction,square):    print("You are moving",direction, "from", square)Move = getMove(direction,square)print(Move)    # Determining if the players tile is at the edge of a board horizantally or vertically:def isEdge(pos,square):    if square == 1 or square == 2 or square == 3 or square == 4 or square == 5:        print("You are on the northern edge.")    elif square == 7 or square == 14 or square == 21 or square == 28 or square == 35:        print("You are at the western edge.")    elif square == 6 or square == 13 or square == 20 or square == 27 or square == 34:        print("You are at the eastern edge.")    elif square == 43 or square == 44 or square == 45 or square == 46 or square == 47:        print("You are at the southern edge.")edge = isEdge(pos,square)print(edge)# Determining if the player's tile has a similar character adjacant to it:#def isAdjacentToSame(pos,board):    #def moveChar(pos,board,direction):`
Last edited by micseydel on Tue Jun 10, 2014 6:51 pm, edited 3 times in total.
Reason: Yoriz: First post lock, Added code tags. micseydel: changed title to not include "help me".
OwenBarrington

Posts: 1
Joined: Tue Jun 10, 2014 4:02 pm

### Re: Help me please. I have to get rid of q but don't know ho

Welcome to the forum.
Please read the new users read this link in my signature.
Due to the reasons discussed here we will be moving to python-forum.io/ on October 1 2016
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.

Yoriz

Posts: 1672
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

### Re: Help me please. I have to get rid of q but don't know ho

Yeah, Q can be a dick.
I fail to remember how Jean-Luc got rid of him, but maybe you can google it.
Friendship is magic!

R.I.P. Tracy M. You will be missed.

stranac

Posts: 1790
Joined: Thu Feb 07, 2013 3:42 pm

Return to General Coding Help

### Who is online

Users browsing this forum: Bing [Bot] and 10 guests