Python Forum
not controlling this loop well
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
not controlling this loop well
#2
Following uses f-string and requires python 3.6 or newer.
number on same line as lyric:
lyrics = ["Today I don't feel like doing anything", "I just wanna lay in my bed", "Don't feel like picking up my phone", "So leave a message at the tone"]

for n, line in enumerate(lyrics):
    print(f'{n}: {line}')
output:
Output:
0: Today I don't feel like doing anything 1: I just wanna lay in my bed 2: Don't feel like picking up my phone 3: So leave a message at the tone
On separate lines:
lyrics = ["Today I don't feel like doing anything", "I just wanna lay in my bed", "Don't feel like picking up my phone", "So leave a message at the tone"]

for n, line in enumerate(lyrics):
    print(f'{n}:\n{line}')
output:
Output:
0: Today I don't feel like doing anything 1: I just wanna lay in my bed 2: Don't feel like picking up my phone 3: So leave a message at the tone
Reply


Messages In This Thread
not controlling this loop well - by juan_de_comala - Mar-30-2019, 08:14 PM
RE: not controlling this loop well - by Larz60+ - Mar-30-2019, 08:31 PM
RE: not controlling this loop well - by woooee - Mar-30-2019, 11:15 PM

Forum Jump:

User Panel Messages

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