Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
learning to while loop
#1
colours = []
while repeat = True
    colours.append(input('Please enter a favourite color:'))
    answer = input('Would you like to add another favourite color? (Y/N)')
    if answer = "N" or "n":
        repeat = False
    else:
        print("More colours!")
print("So your favourite colours are:")
print(colours)
I've been doing google searching trying to find out why my while loop gets a syntax error. It's pointing at "while repeat = true" but I don't understand why it wouldn't work. I've looked at other websites and while they aren't using the True/False boolean like I am, I should be able to do it this way shouldn't I?

I tried parentheses "while(repeat = True)" but that didn't work either.

I've been learning from a no starch press book (Python Crash Course) but this isn't from the book. It's more free-form so there's not much I can do at this point except ask for help.
Reply


Messages In This Thread
learning to while loop - by iofhua - May-23-2019, 03:22 PM
RE: learning to while loop - by perfringo - May-23-2019, 03:31 PM
RE: learning to while loop - by iofhua - May-23-2019, 03:39 PM
RE: learning to while loop - by perfringo - May-23-2019, 03:42 PM
RE: learning to while loop - by iofhua - May-23-2019, 03:50 PM
RE: learning to while loop - by perfringo - May-23-2019, 04:20 PM
RE: learning to while loop - by iofhua - May-23-2019, 04:27 PM
RE: learning to while loop - by DarkCraftPlayz - May-24-2019, 09:46 AM

Forum Jump:

User Panel Messages

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