Python Forum
Is it possible to check for a key error in a python dictionary?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is it possible to check for a key error in a python dictionary?
#1
Hello,

Hope you are well.

Using a dictionary "Undergrads" with is list of students, it has a key made of two values to make each student unique their name and overall rank in the class.

I want to focus on the top 10 students.

In this program a user inputs a name, I want to use an if statement to check if the student is in the top 10.

Is there a check if statement I can use to check to see if a student is in the top 10?


strStudent

marks = []

for i in range(1,11):
marks.append(Undergrads[strStudent, i][15])
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  check if element is in a list in a dictionary value ambrozote 4 1,962 May-11-2022, 06:05 PM
Last Post: deanhystad
  Error while checking for key in Dictionary onenessboy 5 2,662 Aug-14-2020, 01:06 PM
Last Post: onenessboy
  Convert List of Dictionary to dictionary of dictionary list in python kk230689 2 49,796 Apr-27-2019, 03:13 AM
Last Post: perfringo
  Calculation Inside Dictionary Error prophet11 3 2,592 Apr-22-2019, 05:23 AM
Last Post: perfringo
  Dictionary Results Error prophet11 2 2,256 Apr-21-2019, 11:22 PM
Last Post: prophet11
  Error 'object has no attribute' when iterating thru a dictionary mrapple2020 8 6,947 Apr-08-2019, 01:36 AM
Last Post: mrapple2020

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020