Why is dynamically creating variables (from user input) considered to be dangerous to many programmers?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Why is dynamically creating variables (from user input) considered to be dangerous to many programmers?



I saw similar code on a post that allowed one to convert a string into a variable:



x='joke'

exec("%s = %d" % (x,5))



print joke



On the comments below, many people advised against this method and instead recommended using a dictionary to assign values to string. What is so dangerous with this method?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS