Why is dynamically creating variables (from user input) considered to be dangerous to many programmers?
Clash 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.