Python Forum
Help with list homework
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with list homework
#4
(Nov-17-2022, 08:59 PM)Yoriz Wrote: I have added a print statement that shows what is happening in your if statement and that it is always False
def verify_seating_arranngment(cinema):
    line_1 = cinema[0]
    line_2 = cinema[1]
    line_3 = cinema[2]
    for i in line_1:
        print(f"{i} == 1 = {i ==1} and {i+1} == 1 = {i+1== 1} = {i ==1 and i+1== 1}")
        if i ==1 and i+1== 1:
            return False
     
print(verify_seating_arranngment([
    [0, 0, 2, 2, 0, 1, 1],
    [1, 0, 0, 0, 1, 0, 0],
    [0, 1, 0, 0, 0, 1, 0]
]))
Output:
0 == 1 = False and 1 == 1 = True = False 0 == 1 = False and 1 == 1 = True = False 2 == 1 = False and 3 == 1 = False = False 2 == 1 = False and 3 == 1 = False = False 0 == 1 = False and 1 == 1 = True = False 1 == 1 = True and 2 == 1 = False = False 1 == 1 = True and 2 == 1 = False = False None

ok got it, thank you,What do you think is the best way to do it?
Reply


Messages In This Thread
Help with list homework - by eyal123 - Nov-17-2022, 08:40 PM
RE: Help with list homework - by Yoriz - Nov-17-2022, 08:59 PM
RE: Help with list homework - by eyal123 - Nov-18-2022, 11:19 AM
RE: Help with list homework - by deanhystad - Nov-17-2022, 09:17 PM
RE: Help with list homework - by Yoriz - Nov-18-2022, 12:17 PM
RE: Help with list homework - by deanhystad - Nov-18-2022, 03:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Homework - List containing tuples containing dicti Men 4 2,144 Dec-28-2021, 12:37 AM
Last Post: Men
  Sorting list - Homework assigment ranbarr 1 2,313 May-16-2021, 04:45 PM
Last Post: Yoriz
  have homework to add a list to a list using append. celtickodiak 2 2,095 Oct-11-2019, 12:35 PM
Last Post: ibreeden
  Dictionary/List Homework ImLearningPython 22 10,975 Dec-17-2018, 12:12 AM
Last Post: ImLearningPython

Forum Jump:

User Panel Messages

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