Trying to get the integer value of a data table row

What I’m trying to do:
I am trying to print the int value of an entry in a data table
The tale row is question_column and I am trying to print the value shown in the row if the value in question_column is 1

@anvil.server.callable
def alocate_points():
  
        score1 = app_tables.button_capture_from_user.get(question_number = 1)
        print(score1)
        

this is what is printed if the value is 1
<LiveObject: anvil.tables.Row>

Your code fetches you the row. But now you need a particular column of that row to print

score1 = app_tables.button_capture_from_user.get(question_number = 1)['column name']

This will print the value of that particular column.

1 Like

thank you very much
always appreciated

1 Like

question_number is the column and the value I’m looking for in that column is 1.
so if the number 1 appears in any row of the question_column, column.I would like to print 1.
so if I was looking for the number2 (or perhaps I should say value 2) in the question_number column,I would then print 2

score1 = app_tables.button_capture_from_user.get(question_number = 2)[‘question_number’]

This will print 2 if such a value actually exists.

This line of code gets a red line under it,syntax error

@anvil.server.callable
def alocate_points():
score1 = app_tables.button_capture_from_user.get(question_number = 2)[‘question_number’]
print(score2)
any ideas?
and Ive tried altering the indent

I think this error is caused by wrong quotes.

@anvil.server.callable
def alocate_points():
  score1=app_tables.button_capture_from_user.get(question_number = 2)['question_number']
  print(score1)

I changed the quotes and that solved the syntax error but when I run the program I get this error

‘NoneType’ object is not subscriptable (key ‘question_number’)

It appears that there is no value called ‘2’ in your question number column. This is why it returns None as the row

1 Like