Session 3: Python Data Structures And Functions

Hello everyone!

Use this thread to ask questions about topics covered in Session 3.

General rules to follow:

  • Indicate the quiz or exercise name at the beginning of your post.
  • Write down your question in as much detail as you possibly can.
  • If your question involves code, please include it in code blocks below with comments and avoid posting screenshots.

I am having doubts about part 3 of the exercise on dictionaries. In this part, we are required to create a list of all the elements in the dictionary. However, when using the ‘items’ method, I am facing an issue in the subsequent question where we need to iterate through the list. but Dictionary items are not iterable, and it is showing error

I tried converting the dictionary to a list,using list type cast but then only the names are getting into the list.

Hello Sarthak,

Using the ‘items’ method will give all the elements of the list, as you correctly pointed out. And dictionary items are not iterable.

So, try wrapping the dictionary.items() method inside the list function.

Your code will look something like this.

score = list(dict.items())

Hope this helps.

I am facing problem in the exercise -basic of function where destandardization is given

please help me to solve that

edTest(test_de)

# Write a function which takes data, mean and std as input

# and returns de-standardized data

# Make sure you use the correct mean and std for

# data1 and data2 calculated earlier

def destandardize(mean, std, data):

destandardized_data = []

for value in data:

    destandardized_value = (value*std)+mean

    destandardized_data.append(destandardized_value)

    return destandardized_data

file save and submit error in session 3,Exercise: Dictionary and List speed test.

file save and submit error in session 3,Exercise: Dictionary and List speed test.

showing->“File Save Error for ex_scaffold.ipynb”