2

How do I check for a String regardless of case that is already in a List of strings or not?

I have this

current_activities = ['Free WiFi']

if activity in current_activities:
   print("Yes it is already inside")

I want that whether activity = 'Free WiFi' or activity = 'Free WIFI' it should evaluate to true.

  • Both are same I guess "activity = 'Free WIFI' or activity = 'Free WIFI' " – ZdaR Dec 20 '14 at 15:35
  • Sorry ... I have edited .... look now –  Dec 20 '14 at 15:36
  • I have tried the solution from the question which is marked duplicate but does not work –  Dec 20 '14 at 15:37
  • It worked for you ? @mani – ZdaR Dec 20 '14 at 15:38
  • ok as the answers section is being disables so I will try to answer you in the comments itself.... – ZdaR Dec 20 '14 at 15:40
  • for word in current_activities: if word.lower()==activity.lower(): print "Yes it is already inside" – ZdaR Dec 20 '14 at 15:44
  • Please indent the code accordingly, and keep in mind that it will also accept "free wifi", "FREE wifi", "FrEE WiFi" ,etc. – ZdaR Dec 20 '14 at 15:46
  • Can you just modify my code to answer question? You have adde more `FOR` loops .... :P –  Dec 20 '14 at 15:51
  • Sorry but Stackoverflow is not allowing extended conversations in comments, so You have to go with it or contact me somewhere else. – ZdaR Dec 20 '14 at 15:58
  • remove the email comment to avoid spams, gmail would be preferable :) – ZdaR Dec 20 '14 at 16:04

0 Answers0