1

I have to initialize a simple python dictionary as shown below:

dictionary = {
               'a':'dftyj',
               'b':'dftyj'+'__29July2021'
          }

As you see dictionary['b'] is nothing but dictionary['a'] + random string. I was wondering if I could use any sort of pointer to get value from the already existing properties of the dictionary?

1
  • 1
    Define the value for a as a seperate variable before defining the dictionary or define b after making the dictionary Commented Jul 7, 2021 at 7:50

1 Answer 1

1

That is not possible to do while you're creating the dictionary. You have to first create a dictionary and then get something out of it.

dictionary = {}
dictionary['a'] = 'dftyj'
dictionary['b'] = dictionary['a'] + '__29July2021'
Sign up to request clarification or add additional context in comments.

1 Comment

This ain't exactly what I was looking for but still thanks for the idea.

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.