Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble creating loops
#3
Thank you so much for pointing out all those errors, and thank you for the hints!
I've figured out some of them later, sorry, I'm still a beginner.
I've thought about splitting the string, then turning it into a list of integers through a for cycle.
(Also, I don't know how much convenient could it be, but maybe sorting the list, and including the range of the index from to the number of the input, could save time for the loops).
    string.split(',')
    for x in string.split(','):
        d=int(x)
        s.append(d)
   
Anyway, after looking if the number is already in the list, and using the while method pointing j as the len(new_list) in the while method, the sum should be calculated between all the numbers of the list.The index j should get j+=-1 everytime until i and j won't encounter eachother.
Reply


Messages In This Thread
Trouble creating loops - by Den - Oct-19-2019, 07:36 AM
RE: Trouble creating loops - by ibreeden - Oct-20-2019, 12:43 PM
RE: Trouble creating loops - by Den - Oct-20-2019, 01:34 PM
RE: Trouble creating loops - by ibreeden - Oct-23-2019, 05:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help with creating dynamic columns with for loops for stock prices PaDat 2 973 Feb-22-2023, 04:34 AM
Last Post: PaDat
  Trouble with While loops jj432 1 1,876 Oct-19-2019, 01:22 AM
Last Post: Aurthor_King_of_the_Brittons
  Troubble creating loops in PyQt LavaCreeperKing 0 5,576 Mar-02-2017, 08:05 PM
Last Post: LavaCreeperKing

Forum Jump:

User Panel Messages

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