Battleship - Extra credit helpppppppp!

python

#1

This says invalid syntax. What am I doing wrong?

name = input('Player One, what is your name? ')
name_2 = input('Player Two, what is your name? ')
from random import randint
board = []
for x in range(15):
    board.append(["O"] * 15)
def print_board(board):
    for row in board:
        print(" ".join(row))
print('This is the turn of %s' % (name)) 
print_board(board)
x = int(input('Where do you want your first city (row)? '))
a = int(input('Where do you want your first city (collum)? '))
board[x][a] = 'C'
print_board(board)
q = int(input('Where do you want your troops (row)? '))
w = int(input('Where do you want your troops (collum)? '))
board[q][w] = 'T'
print('This is the turn of %s' % (name_2))
print_board(board)
x_2 = int(input('Where do you want your first city (row)? '))
a_2 = int(input('Where do you want your first city (collum)? '))
board[x_2][a_2] = 'C'
print_board(board)
q_2 = int(input('Where do you want your troops (row)? '))
w_2 = int(input('Where do you want your troops (collum)? '))
board[q_2][w_2] = 'T'
print_board(board)
money = 0
profit = 20
city = 10
troops = 5
troops_stuff = 15
for turn in range(15):
    print('This is the turn of %s.' % (name))
    money = money + profit - city - troops
    print('You have %s dollars.' % (money))
    buying = input('Would you like to upgrade or buy anything? You can buy new troops and cities! (yes or no) ')
    if buying == 'yes':
        item = input('What would you like to buy or upgrade? ')
        if item == 'upgrade':
            objec = input('Would you like to upgrade cities or troops? ')
            if objec == 'cities':
                city = 5
                print('You have upgraded your city! You have %s dollars!' % (money))
                ug = True
            else:
                troops = 4
                troops_stuff = 20
        if item == 'buy':
            new = input('What would you like to buy? (cities or troops) ')
            if new == 'cities':
                r = int(input('Where would you like to put your city (row)? '))
                o = int(input('Where would you like to put your city (col)? '))
                board[o][r] = 'C'
                print_board(board)
            else:
                f = int(input('Where would you like to put your troops (row)? '))
                f_2 = int(input('Where would you like to put your troops (col)? '))
                board[f][f_2] = 'T'
                print_board(board)
    else:
        mo = input('Would you like to move your troops? If you want to attack, move to a place that is taken. ')
        if mo == 'yes':
            mov = int(input('Where would you like to move them (row)? '))
            mov_2 = int(input('Where would you like to move them (col)? '))
        while mo == 'T':
            poo = input('Would you like to attack? ')
            if poo == 'yes':
                print('You are attacking!')
            else:
                print('Sorry! That position is currently taken.')
                no = int(input('Chose another (row) ')
                no_2 = int(input('Chose another (col) ')
                board[no][no_2] = 'T'
                board[q][w] = 'O'
                print_board(board)
        else:
            board[q][w] = 'O'
            board[mov][mov_2] = 'T'
            print_board(board)
        else:
            print("Your turn is over")

#8

line 73:

no = int(input('Chose another (row) ')

look at the parentheses


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.