I'm trying to convert an input string to a variable name. Instead of reading the variable which passes the input string as a string - I'd like it to read it as the variable name.
Example:
Input is "r_all"
subreddit = r_all
# Get subreddit
subreddit = input('Which subreddit would you like to see?: ')
# For each post in "hot" python subreddit - print the title/url
for post in subreddit.json()['data']['children']:
print(post['data']['title'], ':', post['data']['url'])
Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.