Python How To Assign 2 Variables in One Part(?)

rookie

Im sorry ı couldn't write decent title. But let me explain.

a list that holds ten variable
list[0] = tshirt
but if user search t-shirt in that list, program should accept it as tshirt.
What Im asking is, can I say

list[0] = "tshirt" or "t-shirt"

if not, must I do that manually or is there any way to do this?

thanks.

Edit: Can any mod fix my title so people can understand the problem and find answer below

Aditya Singh

I remember , I faced this issue too in one of my projects.There is a python library called fuzzywuzzy which tells if two words are similar or not based on the similarity score.Here's an example stuff.

from fuzzywuzzy import fuzz
temp = "t-shirt"
if fuzz.token_sort_ratio("tshirt", temp) > 70:
    print("Found")
if fuzz.token_sort_ratio("TSHIRT", temp) > 70:
    print("Found")
if fuzz.token_sort_ratio("T--SHIRT", temp) > 70:
    print("Found")

It Outputs FOUND for all three statements.

This library provides us a solution to a problem which most of us might have faced.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How Python assign multiple variables at one line works?

How to assign dynamic variables in a for loop in python

Python - How to Automatically Assign Variables to Numerous Inputs

How to assign and call variables from a class in python

How query variables with part of var in SQLite python

Python: How do I assign the indexes of an item in a 2D list to two integer variables?

How to assign the values of one array to the variables in a different array in PHP

How to assign same value to multiple variables in one line?

How to assign multiple variables different values using one function in Javascript

how to split one line with customized separator and assign to variables in BASH?

Python: how to assign multiple values to one key

How to compare two (2) unequal dataframes in Python and assign elements from the one to another?

Python : How to assign ranks to categorical variables within a group in Python

How to assign variables in twig?

How to assign @variables in tableau

How can I extract part of the output of a curl command and assign it to a shell variable - part 2?

Python function: if link in one dataset is a part of a link in another dataset, assign 1, else 0

How to assign the variables used in Modelica_LinearSystems2.ModelAnalysis.Linearize?

How to assign results from 2 separate variables in a third variable?

How do I assign the same array values to 2 different variables

How to assign 2 variables with the same parameters in 1 line

How to assign a string to a row based on variables with numerical values in python

How to assign variables to worker Thread in Python PyQt5?

how to assign variables in a list and not just the list element? (for python)

How to assign a value to the variable based on the existing variables in python?

How to correctly assign local variables to a for-loop in python?

How To Assign Different Column Values To Different Variables In Python

How to assign multiple variables from multidimensional array in python

How to assign dictionary results to individual variables in python3?