Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lists + Empty Lists
#16
Hello Pytho13!! Smile Blush ,

I hope you are well. I know how to solve this problem!

Make a for loop, with the i starting from 1 and ending to 4. Code: for i in range(5):
And inside the loop, put days[i] into weekdays. If you don't understand what I mean,
I mean like when the i value is zero you put the 1st item of "days"(Monday) into the list "weekdays".
By the way here is the code to do that:
for i in range(5):
weekdays.append(days[i])
It will go on until it reaches Saturday.
Now for the next list "weekends".
Make another for loop with i starting from 5 to 6 because days[5] and days[6] are the weekend days.
Code for the for loop: for i in range(5, 7, 1):
Next you need to actually put the weekdays into the "weekends" list.
Now that you have got your for loop, we need to put something inside it!
It's pretty much the same code last time except a little different.
The i starts at 5, and days[5] is Saturday. We need to put Saturday into the "weekends" list.
And the i ends at 6, and days[6] is Sunday. We also need to put Sunday into the "weekends" list.
So the code we need to put inside this for loop is:
weekends.append(days[i])
When the for loop starts, the i will be 5. weekends.append(days[5]) that code will append Saturday into the "weekends" list. When the for loop ends, the i will be 6. weekends.append(days[6]) that code will append Sunday into the "weekends" list.
Hope I was able to solve the problem for you! Sorry this was a long message, I was just trying to explain the easiest I could. Wink If you need any more help on anything please contact me! Have a great day.
Reply


Messages In This Thread
Lists + Empty Lists - by Pytho13 - Mar-22-2021, 06:39 PM
RE: Lists + Empty Lists - by Axel_Erfurt - Mar-22-2021, 06:47 PM
RE: Lists + Empty Lists - by Pytho13 - Mar-22-2021, 06:48 PM
RE: Lists + Empty Lists - by Axel_Erfurt - Mar-22-2021, 06:52 PM
RE: Lists + Empty Lists - by Pytho13 - Mar-22-2021, 06:53 PM
RE: Lists + Empty Lists - by Larz60+ - Mar-22-2021, 06:59 PM
RE: Lists + Empty Lists - by Pytho13 - Mar-22-2021, 07:07 PM
RE: Lists + Empty Lists - by Pytho13 - Mar-22-2021, 07:18 PM
RE: Lists + Empty Lists - by Axel_Erfurt - Mar-22-2021, 07:40 PM
RE: Lists + Empty Lists - by Pytho13 - Mar-22-2021, 08:20 PM
RE: Lists + Empty Lists - by Axel_Erfurt - Mar-22-2021, 08:30 PM
RE: Lists + Empty Lists - by deanhystad - Mar-22-2021, 08:49 PM
RE: Lists + Empty Lists - by Pytho13 - Mar-23-2021, 11:40 AM
RE: Lists + Empty Lists - by snippsat - Mar-23-2021, 01:09 PM
RE: Lists + Empty Lists - by Larz60+ - Mar-23-2021, 09:50 PM
RE: Lists + Empty Lists - by pythonprogrammer1101935 - Mar-26-2021, 08:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare lists w_i_k_i_d 6 328 May-23-2024, 07:23 PM
Last Post: deanhystad
Question Using Lists as Dictionary Values bfallert 8 557 Apr-21-2024, 06:55 AM
Last Post: Pedroski55
  problem with print lists MarekGwozdz 4 789 Dec-15-2023, 09:13 AM
Last Post: Pedroski55
  python convert multiple files to multiple lists MCL169 6 1,700 Nov-25-2023, 05:31 AM
Last Post: Iqratech
  Lists blake7 6 897 Oct-06-2023, 12:46 PM
Last Post: buran
  Trying to understand strings and lists of strings Konstantin23 2 871 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Why do the lists not match? Alexeyk2007 3 907 Jul-01-2023, 09:19 PM
Last Post: ICanIBB
  ''.join and start:stop:step notation for lists ringgeest11 2 2,505 Jun-24-2023, 06:09 AM
Last Post: ferdnyc
  Need help with sorting lists as a beginner Realist1c 1 809 Apr-25-2023, 04:32 AM
Last Post: deanhystad
  Pip lists the module but python does not find it Dato 2 1,362 Apr-13-2023, 06:40 AM
Last Post: Dato

Forum Jump:

User Panel Messages

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