how to get value inside the array result in python?

Question:

I have below code:

test1 = []          
test11=yield context.task_all(result1)
test1.append(test11[0])
test1[0]

test2 = yield context.task_all(result2)

test11 has below value:

['success']
special variables
function variables
0: 'success'
len(): 1

I wanna get only ‘success‘ from the variable test11. How can I get the value?
here is the data which get in variable:
enter image description here

Asked By: microset

||

Answers:

You can get the value of ‘success’ from the variable test11 by accessing the ‘name’ property of the object at index 0 of the result1 array.

To do this, you can use the following code:

value1 = test11[0].state.name

If the value of ‘name’ is ‘success’, the value of ‘value1’ will be ‘success’.

Answered By: Frank Logen

To get the string ‘success’ from the variable test11, you can use the following code:

successString = test11[0]

This will retrieve the first element in the test11 array, which should be the string ‘success’. You can then use this variable in your code as needed.

Answered By: David.C
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.