I am trying this code and its working fine:
phone_list = resp['return'].phone
for phone in phone_list:
x = (phone.name)
print(x)
try:
resp = service.removePhone(name = x)
except Fault:
show_history()
print(x)
gives 3 values: SEP003C53B8F073
, SEP001FBB3669EA
, SEP003A33B8F041
The problem is when I pass this to the try
block (removePhone
) below to delete these 3 phones: it only deletes the first one.
I don't have any idea on how to assign variables to separate output items. Please let me know ho can I achieve this.
This is a protocol of the execution:
>>> phone_list = resp['return'].phone
>>> for phone in phone_list:
... x = (phone.name)
... print(x)
...
SEP001B53B8F075
SEP001FCA3669EA
>>>
>>>
>>> try:
... resp = service.removePhone(name = x)
... except Fault:
... show_history()
... else:
... print('Deleted Phone:')
... print( resp )
...
Deleted Phone:
{
'return': '{C979366C-491D-4F12-B058-ECB789AA326A}',
'sequence': None
}
This code just deleted the second phone (SEP001FCA3669EA
) from the server. The first phone is still there.
" Current Output: X Expected Output: Y
– Raghav salotra Dec 03 '19 at 10:23