2 Replies - 599 Views - Last Post: 10 July 2020 - 02:22 AM Rate Topic: -----

#1 Deadweight77   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 84
  • Joined: 04-May 19

Aligning two list of different data types

Posted 08 June 2020 - 01:52 PM

I'm having trouble with trying to align lists together correctly with one holding an int datatype while the other is of strings. I've been practicing on iterating through a list comprised of college names, while the other list is of total in-state cost. I found out that when printing the list of college names it's all in alphabetical order.

However, the total in-state costs don't align with the appropriate college names. For example, Augustana college, which is first on the names list, has an incorrect tuition cost. So, Augustana has an index of 0 in names but the correct price has an index of 12 in the total cost list.

This post has been edited by Deadweight77: 08 June 2020 - 01:55 PM


Is This A Good Question/Topic? 1
  • +

Replies To: Aligning two list of different data types

#2 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 12121
  • View blog
  • Posts: 20,536
  • Joined: 19-March 11

Re: Aligning two list of different data types

Posted 08 June 2020 - 07:11 PM

Can you show us the input data and how you're handling it?
Was This Post Helpful? 1
  • +
  • -

#3 DK3250   User is offline

  • Pythonian
  • member icon

Reputation: 592
  • View blog
  • Posts: 1,888
  • Joined: 27-December 13

Re: Aligning two list of different data types

Posted 10 July 2020 - 02:22 AM

If there are more than one college in each state and the state-fee is fixed, I suggest two dictionaries: One linking colleges and state and another linking state and price.
In this way you can update the state price in one singe place and you don't need to go through each college if the price changes.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1