Session 2: Python Lists And Loops

Hello everyone!

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

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.

Exercise loops:

Error while submitting

Traceback (most recent call last):
File “/home/univai/jupytest/run4.py”, line 41, in
with open(notebook_path, ‘r’, encoding=‘utf-8’) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/jupyter-49190_cvr-2_adf/challenge_lists.ipynb’

1 Like

Exercise: Loops

Facing error while submitting:

Traceback (most recent call last):
File “/home/univai/jupytest/run4.py”, line 41, in
with open(notebook_path, ‘r’, encoding=‘utf-8’) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/jupyter-49328_cvr-2_adf/challenge_lists.ipynb’

Exercise : Loops

Error while submitting :

Traceback (most recent call last):
File “/home/univai/jupytest/run4.py”, line 41, in
with open(notebook_path, ‘r’, encoding=‘utf-8’) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/jupyter-49327_cvr-2_adf/challenge_lists.ipynb’

Exercise Loops:

Error : test_list

I have reset the scaffold multiple times and tried submitting it but it’s still showing

test_list

Test removed

TypeError Traceback (most recent call last)
Cell In[69], line 3 1 # Using indexing to reverse the sorted list and print the first ten elements 2 reverse_list = sorted_list.reverse()
----> 3 print(reverse_list[:10])

TypeError: ‘NoneType’ object is not subscriptable

Hi Folks I am unable to reverse the list via reverse() function. can you please help ?

Hello Manish,
As stated in the comment above we expected you to use Indexing to reverse the sorted list.
You can use the last index as the starting index and use -1 step.
The reverse() function is an inplace method. It will change the original list and returns None.
Try playing around with the following code to understand this better.

list1 = [0,1,2,3,4,5,6]
list1_reverse = list1.reverse()
print("list1 reversed output : ", list1_reverse)
print("list1 original : ", list1)

Hope this helps.

1 Like