Learning code - different solutions?

Hiya! I’m currently working my way through Replit’s 100 days of code, really enjoying it. I generally try to avoid checking the solutions until I’ve worked out my own solution, and then I’ll click through to watch the solution video to make sure I’ve understood everything/see if there’s anything I’ve missed. I’m up to day 42 now and recently when I check the solution, I’ve coded things in a different way to the solution, but my code has still ran and has worked. Is this okay? Are there specific ways I should be learning to do things or is making it work what counts?
For example, today’s challenge was to make a dictionary, use a loop to output the names of the keys, get the user to input values for those keys, store that in the dictionary and then print out the whole dictionary.
my code:

dictionary = {"Name": None, "Url": None, "Desc":None, "Rating":None, "new thing":None}

for key in dictionary:
  j = input(f"{key}: ")
  dictionary.update({key:j})
print()
for key, value in dictionary.items():
  print(f"{key}: {value}")

solutions code:

website = {"name": None, "url": None, "desc": None, "rating": None}
for name in website.keys():
  website[name] = input(f"{name}: ")
print()
for name, value in website.items():
  print(f"{name}: {value}")

Is this okay? I don’t want to be creating bad habits or missing things by doing things a different way. Sorry if this is a dumb question!

Hi @ahollyborealis , not following the solution given is fine. Replit encourages you to get creative and come up with your own ways of doing things! It helps you think out of the box!

2 Likes

thank you! Is this still true for working at a higher level, or in a software job? Just want to make sure I’m not creating bad habits

In a job, there is no right or wrong (not that I’m working). I feel that getting it to work is the best thing. I mean, it’s not like your boss is going to give you a task and then give you an answer key to check with your solution, right? Getting it to work (in my opinion) is the thing you want.

1 Like

thank you :slight_smile: appreciate you taking the time as well! x