Python Forum
Unable to implement loop count
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to implement loop count
#1
Hello all,
I have difficulty trying to count and print number of loops and implement it as solution number.
The codes are below. Any help would be appreciated!

def solutionnames():
    numofsol= input("How many solutions are there?")
    listofnames= []
    loops=0
    for i in range(int(numofsol)):
        loops +=1
        NamesofSol=input("Name of Solution",str(loops))
        listofnames.extend([NamesofSol])
    print(listofnames)
    return(listofnames)

solutionnames()  
Reply


Messages In This Thread
Unable to implement loop count - by zukochew - Jul-25-2018, 05:17 PM
RE: Unable to implement loop count - by Larz60+ - Jul-25-2018, 05:35 PM
RE: Unable to implement loop count - by zukochew - Jul-25-2018, 05:44 PM
RE: Unable to implement loop count - by ichabod801 - Jul-25-2018, 06:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  While loop that needs to count up ImLearningPython 4 3,075 Dec-17-2018, 02:30 PM
Last Post: ImLearningPython
  Count Letters in a Sentence (without using the Count Function) bhill 3 5,198 Jun-19-2018, 02:52 AM
Last Post: bhill

Forum Jump:

User Panel Messages

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