r/pythonhelp • • May 13 '23

CS50P - Lecture 1 - Conditionals

Hi everyone. First time posting here, apologies if I have broken any rules.

I am attempting to run code of the first lecture of the titled series, named CS50P - Lecture 1 - Conditionals. The link is attached, where I am up to the 54th minute. CS50P - Lecture 1 - Conditionals.

I believe I have written up the code equivalently in my VS Code house.py programme but when I attempt to run “python3 house.py”, I receive “invalid syntax” pointing at the letter e in “match name:” May someone please point out what I have done incorrectly?

I have also attached my code for reference.

name = input("What's your name? ")

match name: case "Harry": print("Gryffindor") case "Hermione": print("Gryffindor") case "Ron": print("Gryffindor") case "Draco": print("Slytherin")

Thanks!

3 Upvotes

1 comment sorted by

1

u/Satiivas1 May 13 '23

In python, the indentation matters so please copy-paste your code to https://pastebin.com/ f.e and post the link here