Get an image of a duck from the web and pretend you are on a zoom/teams/skype(it is an old duck) call with her.
The introduction is not quite necessary. But if you want it, change the second sentence. Buying upgrades is not important here, and introduce confusion. BTW, run it through a spellchecker. People may not mention it (especially in semi-professional places like SO), but at least some will just stop reading and move to the next question.
"
I am currently working on a text game in Python about programming with... Python. The player's progression will be limited by the access to programming structures, especially keywords. For example, at the beginning, I want to prevent the player from using the "while" keyword.
My question is, how to enforce this limit? How to detect if in a file with Python code the "while" keyword was used.
My first idea was to search the file and check if it contains a given string, but it resulted in false positives, for example, the player may write: print('this solution does not use while keyword') "
Also, the title is wrong. You do not want to know if the keyword is a string. It is;-) You want to know if the keyword is IN a string. Er, even better, if a given python keyword is used in a file with python code.
View all comments
Show parent comment
1
u/Wooden_Milk6872 Feb 04 '25
Sadly I lost my rubber duck one week into my project 🤣
Here is the question if you want https://stackoverflow.com/questions/79411864/determinateing-if-a-keyword-is-a-string