Skip to content

Instantly share code, notes, and snippets.

@cibofdevs
Last active July 10, 2024 02:14
Show Gist options
  • Save cibofdevs/967df5e853c7f1755ba4920b502b7922 to your computer and use it in GitHub Desktop.
Save cibofdevs/967df5e853c7f1755ba4920b502b7922 to your computer and use it in GitHub Desktop.
# Create an empty string and assign it to the variable lett.
# Then using range, write code such that when your code is run, lett has 7 b’s ("bbbbbbb").
lett = ''
for i in range(7):
lett += 'b'
print(lett, end='')
@mrmecks
Copy link

mrmecks commented Aug 25, 2020

this isn't correct. based on the question, the right answer will be;

lett = ' '
for i in range(7):
lett = 'b'*7
print(lett)

so that for each iteration, 'b' is printed 7 times. I believe that is what the question is asking

@saxenaiway
Copy link

A small correction to loop_lett_val.py
lett = ''
for i in range(7):
lett += 'b'
print(lett)

because indent continues to print the loop, Just for info

@Kaushal0709
Copy link

We

this isn't correct. based on the question, the right answer will be;

lett = ' '
for i in range(7):
lett = 'b'*7
print(lett)

so that for each iteration, 'b' is printed 7 times. I believe that is what the question is asking

I felt this is the correct thing we should so based on the question asked.
If we do
lett += 'b'

It will print more number of b's what we need as per the question.

@chinmay534
Copy link

lett = ''
for i in range(7):
lett += 'b'
print(lett, end='')

@Rafi2348
Copy link

Rafi2348 commented Feb 1, 2023

lett= ' '
for i in range(7):
lett = lett+('b')
print(lett)

@Sayed10000002
Copy link

lett = " "
range(7)
lett = "b"*7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment