passing dictionay as argument

Frank Millman frank at chagford.com
Mon Jun 13 07:39:35 EDT 2016


"Arshpreet Singh"  wrote in message 
news:0b6372ce-3f16-431b-9e72-42d5c935df14 at googlegroups.com...

> I have to pass dictionary as function argument for following code:

[...]

> result = authorize.Transaction.sale({
>     'amount': 40.00,
>
>     'credit_card': {
>         'card_number': '4111111111111111',
>         'expiration_date': '04/2014',
>         'card_code': '343',
>     }
>

[...]

> I want to define 'credit-card' dictionary as argument in the function as 
> follows but it returns syntax error:
>
> # define dictionary outside the function call:
> credit_card={
>         'card_number': '4111111111111111',
>         'expiration_date': '04/2014',
>         'card_code': '343',
>     }
>

[...]

> result = authorize.Transaction.sale({'amount': 40.00,credit_card})

Try this -

    result = authorize.Transaction.sale({'amount': 40.00, 
'credit_card':credit_card})

Frank Millman




More information about the Python-list mailing list