0

I have this output

(10.76, 27.73)

and I want to assign it to a key as a value, here is a code

dictionary = {'whatever':'whatever, 'KEY':'I need this output(tuple) here'} 

Also, little detail, I would prefer to keep the comma, but if not possible i'll just add it on my own, that's ok.

Thank you

2 Answers 2

2

Simply assign it.

>>> t = (10.76, 27.73)
>>> d = {}
>>> d['key'] = t
>>> d
{'key': (10.76, 27.73)}
Sign up to request clarification or add additional context in comments.

Comments

0

mytuple = (10.76, 27.73) dictionary = {'whatever':'whatever', 'KEY':mytuple}

{'KEY': (10.76, 27.73), 'whatever': 'whatever'}

or

mytuple = (10.76, 27.73) dictionary = {'whatever':'whatever', 'KEY':str(mytuple)}

{'KEY': '(10.76, 27.73)', 'whatever': 'whatever'}

Comments

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.