Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7572369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:54:32+00:00 2026-05-30T15:54:32+00:00

how can i rename key value in python? i have this code : t

  • 0

how can i rename key value in python?

i have this code :

t =  { u'last_name': [u'hbkjh'], u'no_of_nights': [u'1'], u'check_in': [u'2012-03-19'], u'no_of_adult': [u'', u'1'], u'csrfmiddlewaretoken': [u'05e5bdb542c3be7515b87e8160c347a0'], u'memo': [u'kjhbn'], u'totalcost': [u'1800.0'], u'product': [u'4'], u'exp_month': [u'1'], u'quantity': [u'2'], u'price': [u'900.0'], u'first_name': [u'sdhjb'], u'no_of_kid': [u'', u'0'], u'exp_year': [u'2012'], u'check_out': [u'2012-03-20'], u'email': [u'ebmalifer@agile.com.ph'], u'contact': [u'3546576'], u'extra_test1': [u'jknj'], u'extra_test2': [u'jnjl'], u'security_code': [u'3245'], u'extra_charged': [u'200.0']}
key = {str(k): str(v[0]) for k,v in t.iteritems() if k.startswith('extra_')}
array = []
for val in key:
    data = str(val) + ' = ' + key[val] + ','
    array.append(data)
print array

it give me this :

["extra_charged = 200.0,", "extra_test1 = jknj,", "extra_test2 = jnjl,"]

what should i do to remove the 'extra_' and it makes the output like this:

["CHARGED = 200.0,", "TEST1 = jknj,", "TEST2 = jnjl,"]

can anyone have an idea about my case?
thanks in advance …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:54:34+00:00Added an answer on May 30, 2026 at 3:54 pm

    i found this .replace()

    and i do like this ..

    data = str(val).replace("extra_","").upper() + ' = ' + key[val] + ','
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I use SMO to rename the physical .mdf .ndf .ldf files. This
I am having a NSMutableDictionary . I have to dynamically rename any Key in
I have a table with one field that can point to a foreign key
I have correctly initialized YouTubeService. I can move/delete/rename playlist entries, but when I try
I have a question about defining Foreign Key in EF Code First Fluent API.
How can I rename a virtual directory (i.e., change the Virtual Path name) in
How can I rename all hidden directories under the current directory in DOS? I've
I can run RENAME TABLE student TO student_new ; The command is same and
Given a zipfile with an unknown directory, how can I rename or move that
Can I safely rename the cygdrive folder? Also, I would like to add other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.