0

while doing an assignment i am struck to a question that how do i make a string from row i am having the following problem

def make_str_from_row(board, row_index): 

make_str_from_row([['A', 'N', 'T', 'T'], ['X', 'S', 'O', 'B']], 0) 

str = "".join[(make_str_from_row[0][0])] 

print(str)

the answer should be 'ANTT'

but i am getting an error

TypeError: 'function' object is not subscriptable

1 Answer 1

0

Use "".join(['A', 'N', 'T', 'T'])

So in your example:

a = ([['A', 'N', 'T', 'T'], ['X', 'S', 'O', 'B']], 0)
str = "".join(a[0][0])
print(str)

From the initial question I assumed you used a tuple.

Based on your comment:

def make_str_from_row(board, row_index):
    return "".join(board[row_index])
Sign up to request clarification or add additional context in comments.

3 Comments

Sir, thanks for the code but "".join is not working within a function I am getting an error 'function' object is not subscriptable
Try to search stackoverflow. I found this: stackoverflow.com/questions/9339213/… without your code I can't answer that question
def make_str_from_row(board, row_index): make_str_from_row([['A', 'N', 'T', 'T'], ['X', 'S', 'O', 'B']], 0) str = "".join[(make_str_from_row[0][0])] print(str)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.