Last active
July 10, 2024 02:14
-
-
Save cibofdevs/967df5e853c7f1755ba4920b502b7922 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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='') |
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.
lett = ''
for i in range(7):
lett += 'b'
print(lett, end='')
lett= ' '
for i in range(7):
lett = lett+('b')
print(lett)
lett = " "
range(7)
lett = "b"*7
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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