0

How do i solve for valueerror in python?

I'm getting value error when i compare string elements. I've tried using lambda function to assign and check for equality but it returns bool which I'm unable to use further. Example: DEL BOM DEL I've tried converting this to a list and check str[0]==str[2] which returns an error. Any assistance would be greatly appreciated.

10th Dec 2019, 6:23 PM
Ankit Kaushik
Ankit Kaushik - avatar
3 Respuestas
+ 3
I am not completely sure what you are trying to accomplish. Can you maybe explain in more detail?
10th Dec 2019, 6:30 PM
Louis
Louis - avatar
+ 1
If I'm understanding correctly, you want to check, from the string "DEL BOM DEL", that the first and third words are the same, right? string = "DEL BOM DEL" lst = string.split() print(lst[0] == lst[2]) # true
10th Dec 2019, 6:31 PM
Russ
Russ - avatar
0
What Russ said is correct. Louis also has a point, you are not being specific in relation to your problem.
10th Dec 2019, 7:41 PM
Gonçalo Magalhaes
Gonçalo Magalhaes - avatar