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 7789299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:15:25+00:00 2026-06-01T21:15:25+00:00

How do I convert string into integers in this dictionary then loop through it

  • 0

How do I convert string into integers in this dictionary then loop through it without getting errors like invalid literal for int() with base 10 🙁

mydict = {('6.0', '1.0'): '345.2', ('3.0', '9.0'): '632.7',
    ('2.0', '3.0'): '222.4', ('1.0', '4.0'): '672.1', ('8.0', '6.0'): '822.6',
    ('3.0', '8.0'): '225.5', ('7.0', '7.0'): '534.0', ('4.0', '7.0'): '599.3',
    ('8.0', '9.0'): '273.5', ('5.0', '3.0'): '822.5', ('4.0', '2.0'): '326.6'}

in which (key1, key2): value

I would also like to loop through this dictionary, and calculate using this formula…

((key1 * 360 / key2 * 180) + value)

for each key pair. Then, I would print out the 3 largest value resulted from the calculation. Is this possible?

  • 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-06-01T21:15:26+00:00Added an answer on June 1, 2026 at 9:15 pm

    You can do the following:

    res = map(lambda x: (float(x[0][0]) * 360.) / (float(x[0][1]) * 180.) + float(x[1]), mydict.items())
    

    That will produce something like :

    [357.2, 633.37]
    

    To get the 3 largest:

    sorted(res, reverse=True)[0:3]
    

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to convert this string into DateTime. Tue Aug 19 15:05:05 +0000 2008
In a Dictionary, How to convert a string into a list? Let x =
Using PHP, I'd like to convert a string containing a Roman number into its
I am getting the following error: Can't convert String into Integer (TypeError) It is
I need to convert a string of comma separated integers into a list of
How would you convert an arbitrary string into a unique integer, which would be
how do you convert a string into a long. for int you int i
Is there a standard way / C# library to convert a string into a
I am trying to convert a string value into a name of an attribute
i am trying to convert a LPCSTR string into LPCTSTR string. i want to

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.