Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
list1 position = list 2?
#5
I think I got it idk if its sound though
def test(text):


    list1 = ['1', '2', '3', '4', '5']
    list2 = ['6', '7', '8', '9', '10']
    for word in text.split():


        if word.lower() in list1:
            x = list1.index(text)
            return list2[x]

haha didn't see your reply yeah pretty much same thing but yours is a bit more clean so ill go with that but thank you.
Reply


Messages In This Thread
list1 position = list 2? - by Nickd12 - Sep-20-2020, 03:46 AM
RE: list1 position = list 2? - by bowlofred - Sep-20-2020, 04:06 AM
RE: list1 position = list 2? - by Nickd12 - Sep-20-2020, 04:15 AM
RE: list1 position = list 2? - by bowlofred - Sep-20-2020, 04:20 AM
RE: list1 position = list 2? - by Nickd12 - Sep-20-2020, 04:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  List Creation and Position of Continue Statement In Regular Expression Code new_coder_231013 3 1,737 Jun-15-2022, 12:00 PM
Last Post: new_coder_231013
  item = index position - list of list RavCOder 9 4,280 Dec-02-2019, 05:24 PM
Last Post: ThomasL
  Help with code/URGENT/Adding position to register list Laxman 3 3,789 Apr-23-2017, 04:48 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020