Python Forum
don't know indenting of break and continue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
don't know indenting of break and continue
#1
I was trying to get this output...

My Seven Favorite Musical Artists

Enter Musical Artist: Drake
Enter Musical Artist: Cardi B
Enter Musical Artist: Justin Bieber
No Way!
Enter Musical Artist: Ariana Grande
Enter Musical Artist: Travis Scott
Enter Musical Artist:
That's less than seven, but OK

1. Drake
2. Cardi B
4. Ariana Grande
5. Travis Scott

End of Favorites!

I wrote this code and definitely understand why it has errors, I just don't have ideas on how to fix them because I don't really know how and where to place "breaks" and "continues".

print("My Seven Favorite Musical Artists\n")

output = ""

for ii in range(1, 8):
    artist = input("Enter Musical Artist: ")
    output = output + str(ii) + ". " + artist + "\n"

    if artist.lower() == "justin bieber":
        break
    
        print("No way!")
        continue

print("\n" + output)

print("End of Favorites!")
Reply


Messages In This Thread
don't know indenting of break and continue - by Colin999 - Sep-18-2020, 07:48 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sublime Text + Anaconda not indenting Python code correctly Maxximiliann 0 2,025 Jun-13-2020, 06:09 PM
Last Post: Maxximiliann
  Conditionals, while loops, continue, break (PyBite 102) Drone4four 2 3,037 Jun-04-2020, 12:08 PM
Last Post: Drone4four
  IDLE indenting 29 columns after defining function Cosmo_Kane 1 2,453 Jun-03-2018, 08:53 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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