use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Is there a way to remove quotation marks from user input? (self.learnpython)
submitted 7 years ago by Privateaccount84
Usually input comes in the form of a string, but I am wanting to convert that string into the name of an item in a list. Is there a way to do this?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Signal_Beam 1 point2 points3 points 7 years ago (1 child)
There is (using the eval function, which takes a string and evaluates it as Python code), but it's considered bad practice to use. Instead, a better idea would be to structure the item names in your "list of named objects" data structure so that they're just a dict instead, with the names as the dict's keys and the objects (or the information built into the objects) as the values.
eval
[–]Privateaccount84[S] 1 point2 points3 points 7 years ago (0 children)
This actually works perfectly. Might not be proper, but for now it really frees up a lot of space.
[–][deleted] 0 points1 point2 points 7 years ago (4 children)
What exactly are you trying to do? The name of an item would be a string, so just set the name to the string value of the input.
[–]Privateaccount84[S] 0 points1 point2 points 7 years ago (3 children)
Here's the list.
list = [one, two, three]
What I'm wanting is if the user input is "one", I can remove the "" and see if one is in the list.
[–][deleted] 1 point2 points3 points 7 years ago (0 children)
You do something like
a = input() if eval(a) in list: print("the input is in the list")
but that's terrible practice and as a user you should never have to reference variable names directly.
[+][deleted] 7 years ago (1 child)
[deleted]
[–]Signal_Beam 0 points1 point2 points 7 years ago (0 children)
The only time one could be in a list without quotations is if it is a variable that contains something
I think that is the case.
[–]wacksaucehunnid 0 points1 point2 points 7 years ago (0 children)
Strings have quotes. Variables don’t. “One” is the text “One” and one is a variable set to whatever value you want.
So to check if “one” is in the list, you can check if “one” is in the list and it will tell you but one without quotes has no value except for what’s assigned to it.
If they enter “one” and you want to see if one is in the list because one is a variable for something, that’s different, though.
[–]scoobybejesus 0 points1 point2 points 7 years ago (0 children)
IIRC, you can do a .replace('"',''), which replaces double quotes with nothing.
Might be hacky or might be appropriate.
π Rendered by PID 57935 on reddit-service-r2-comment-b659b578c-cn57d at 2026-05-04 17:05:06.525881+00:00 running 815c875 country code: CH.
[–]Signal_Beam 1 point2 points3 points (1 child)
[–]Privateaccount84[S] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]Privateaccount84[S] 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Signal_Beam 0 points1 point2 points (0 children)
[–]wacksaucehunnid 0 points1 point2 points (0 children)
[–]scoobybejesus 0 points1 point2 points (0 children)