Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day 10 Level 3 Exercise 3 #558

Open
BVenetta opened this issue Jul 13, 2024 · 1 comment
Open

Day 10 Level 3 Exercise 3 #558

BVenetta opened this issue Jul 13, 2024 · 1 comment

Comments

@BVenetta
Copy link

BVenetta commented Jul 13, 2024

Go to the data folder and use the countries_data.py file.

This is the level 3 exercise 3 for day 10. I am struggling with how exactly i import and use the list? dictionary? to be able to extract stuff so that i can actually do the exercises. Could someone be able to help with this? I managed to do it for country.py by doing the following and I tried the same for countries_data.py but it doesnt seem to work.

import sys
import os

# Determine the current and parent directory paths
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.abspath(os.path.join(current_dir, os.pardir))

# Add the parent directory to sys.path
sys.path.append(parent_dir)

from data.countries import countries```
@njlyon0
Copy link

njlyon0 commented Nov 12, 2024

I ran into this same issue!

I was able to tweak a Stack Overflow post + some code from the 'modules' day (day 12) to get the following to work:

import countries_data
countries_data.countries[1]

Note though that I also needed to add countries = to the start of the first line of countries-data.py and change the dash in the filename to an underscore (i.e., countries_data.py).

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants