Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting For Loop Counter
#1
I am trying to set the counter to the one less if the input does not match with list. However, it seems that it does not set the counter. Any idea please?

team=["Arsenal","Liverpool","New Castle","Tottenham"]

t_ins=[]

count=0

for i in range(count,4):
    names=str(input("Please enter the name of a Football Club "))
    if names not in team:
        print("The name inputed does not exist. The team names are ",team)
        print("Try Again ")
        count=count-1
        continue
    else:
        t_ins.append(names)


print(t_ins)
Output:
Please enter the name of a Football Club chelse The name inputed does not exist. The team names are ['Arsenal', 'Liverpool', 'New Castle', 'Tottenham'] Try Again Please enter the name of a Football Club Arsanal The name inputed does not exist. The team names are ['Arsenal', 'Liverpool', 'New Castle', 'Tottenham'] Try Again Please enter the name of a Football Club Arsenal Please enter the name of a Football Club Liverpool ['Arsenal', 'Liverpool']
Reply


Messages In This Thread
Setting For Loop Counter - by rturus - Dec-07-2022, 12:21 PM
RE: Setting For Loop Counter - by DeaD_EyE - Dec-07-2022, 12:49 PM
RE: Setting For Loop Counter - by deanhystad - Dec-07-2022, 01:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Setting maximum value of Range() in For loop pmt 4 2,643 Aug-04-2019, 02:38 PM
Last Post: pmt
Question [Help] How to end While Loop using counter? {Screenshot attached} vanicci 2 3,119 Aug-02-2018, 10:09 PM
Last Post: vanicci
  [Tkinter] Loop Counter for OptionMenu Creation JP_ROMANO 4 5,183 Sep-29-2017, 06:29 PM
Last Post: JP_ROMANO

Forum Jump:

User Panel Messages

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