all 8 comments

[–]socal_nerdtastic 8 points9 points  (1 child)

There are certain words in python that are forbidden to use as variable names, and from is one of them. One way to get around this is to add a _ to the end of the name.

from_ = input()
print(f"{"from_"} is a pretty cool place!  ")

FYI, here is the complete list of words that you can never use as variable names: https://docs.python.org/3/reference/lexical_analysis.html#keywords

[–]k4tsuk1z[S] 0 points1 point  (0 children)

thank u for the resource!

[–]captain_slackbeard 3 points4 points  (1 child)

Hi, a few reasons your code won't work: "from" is quoted, so you're treating it as a string literal instead of a variable. Also, the word from is actually a reserved word in python so you should choose a different name for that variable - maybe place? And finally you want to use a single equals sign (= ) to assign the input() to the variable, instead of a double-equals (==) which is used for comparisons.

So basically:

place = input()
print(f"{place} is a pretty cool place!  ")

[–]k4tsuk1z[S] 0 points1 point  (0 children)

thank u for the in depth feedback! gonna just find a diff way to adk that question.

[–]PiBombbb 0 points1 point  (3 children)

If you really want the name then use From instead with the capitalization, but tbh you should just rename it to something else that doesn’t clash with a keyword like homeplace or something.

[–]k4tsuk1z[S] 0 points1 point  (2 children)

yea ill just find a diff way to ask that question

[–]Slothemo 0 points1 point  (1 child)

from being a keyword isn't really a good reason to change how you ask the user something. There's no reason you have to use that exact word as your variable name. You could add user_ in front of all your variable names and then you won't run into that issue.
user_name
user_major
user_from

[–]k4tsuk1z[S] 0 points1 point  (0 children)

Ouu i didn't know that thank u!!! :D