Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to work with list
#1
Hi all,
I am new to Python. I am doing an application. the application takes 20 names of individuals then prompts user to input out of 20 individual who came first, second, third..... twentieth.
According to the ranking then points allocated for every individual for the first place 100, second 95, third 90... so on.

However, I am finding to very difficult to allocate the points as not sure how to find out who came first and second. The code is below.

Any help will be apricated.

names=[]

history=[]
maths=[]

for i in range(0,20):
    nam=input("Please enter the name of competitor ")
    names.append(nam)
order=["first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh","twelfth",
       "thirteenth","fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth","twentieth"]

for i in range (0,20):
    print("Please enter the name of the individual who came ",order[i],"in History Quiz ")
    a=input()
    history.append(a)

for i in range (0,20):
    print("Please enter the name of the individual who came ",order[i],"in Maths Quiz ")
    a=input()
    maths.append(a)


if names[0]==history[0]:
    print(names[0])
elif names[1]==history[0]:
    print(names[1])
elif names[2]==history[0]:
    print(names[2])
elif names[3]==history[0]:
    print(names[3])
elif names[4]==history[0]:
    print(names[4])
elif names[5]==history[0]:
    print(names[5])
elif names[6]==history[0]:
    print(names[6])
elif names[7]==history[0]:
    print(names[7])
elif names[8]==history[0]:
    print(names[8])
elif names[9]==history[0]:
    print(names[9])
elif names[10]==history[0]:
    print(names[10])
elif names[11]==history[0]:
    print(names[11])
elif names[12]==history[0]:
    print(names[12])
elif names[13]==history[0]:
    print(names[13])
elif names[14]==history[0]:
    print(names[14])
elif names[15]==history[0]:
    print(names[15])
elif names[16]==history[0]:
    print(names[16])
elif names[17]==history[0]:
    print(names[17])
elif names[18]==history[0]:
    print(names[18])
else:
    print(names[19])


if names[0]==maths[0]:
    print(names[0])
elif names[1]==maths[0]:
    print(names[1])
elif names[2]==maths[0]:
    print(names[2])
elif names[3]==maths[0]:
    print(names[3])
elif names[4]==maths[0]:
    print(names[4])
elif names[5]==maths[0]:
    print(names[5])
elif names[6]==maths[0]:
    print(names[6])
elif names[7]==maths[0]:
    print(names[7])
elif names[8]==maths[0]:
    print(names[8])
elif names[9]==maths[0]:
    print(names[9])
elif names[10]==maths[0]:
    print(names[10])
elif names[11]==maths[0]:
    print(names[11])
elif names[12]==maths[0]:
    print(names[12])
elif names[13]==maths[0]:
    print(names[13])
elif names[14]==maths[0]:
    print(names[14])
elif names[15]==maths[0]:
    print(names[15])
elif names[16]==maths[0]:
    print(names[16])
elif names[17]==maths[0]:
    print(names[17])
elif names[18]==maths[0]:
    print(names[18])
else:
    print(names[19])
    
Reply


Messages In This Thread
How to work with list - by kafka_trial - Jan-12-2023, 11:24 AM
RE: How to work with list - by rob101 - Jan-12-2023, 03:22 PM
RE: How to work with list - by kafka_trial - Jan-16-2023, 11:39 AM
RE: How to work with list - by rob101 - Jan-17-2023, 05:25 PM
RE: How to work with list - by kafka_trial - Jan-23-2023, 04:21 PM
RE: How to work with list - by deanhystad - Jan-23-2023, 04:34 PM
RE: How to work with list - by deanhystad - Jan-12-2023, 05:12 PM
RE: How to work with list - by rob101 - Jan-23-2023, 04:31 PM
RE: How to work with list - by jefsummers - Jan-24-2023, 01:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why do I have to repeat items in list slices in order to make this work? Pythonica 7 1,355 May-22-2023, 10:39 PM
Last Post: ICanIBB
  Beginner: Code not work when longer list raiviscoding 2 832 May-19-2023, 11:19 AM
Last Post: deanhystad
  how does .join work with list and dictionaries gr3yali3n 7 3,330 Jul-07-2020, 09:36 PM
Last Post: bowlofred
  A strange list, how does this work? Pedroski55 1 1,726 May-13-2020, 11:24 PM
Last Post: snippsat
Question Why does modifying a list in a for loop not seem to work? umut3806 2 2,311 Jul-22-2019, 08:25 PM
Last Post: umut3806
  Example of list comprehensions doesn't work Truman 17 10,891 May-20-2018, 05:54 AM
Last Post: buran
  List 3 dimensions reference does not work Mario793 1 2,656 Mar-02-2018, 12:35 AM
Last Post: ka06059
  Trying to figure out how list comprehensions work tozqo 4 4,028 Jul-11-2017, 01:26 PM
Last Post: ichabod801
  Why list(dict.keys()) does not work? landlord1984 5 13,676 Feb-02-2017, 05:52 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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