The second loop basically just creates the same content that’s already in line so it wants you to print that again instead.
I wonder what it would say to
name = "World"
print(f"+{'':-^{len(name)}}+\n|{name}|\n+{'':-^{len(name)}}+")
4
الله @lemmy.world - 4mon
4
vintageballs @feddit.org - 4mon
Drop the second loop entirely and just do print(line + '+') again at the end - line and lin2 contain the exact same string so it's unnecessary to construct it twice.
2
الله @lemmy.world - 4mon
ohhh this is the answer i was looking for
others suggested me some shit like
name = "World"
print(f"+{'':-^{len(name)}}+\n|{name}|\n+{'':-^{len(name)}}+")
i was confused AF
1
MyNameIsRichard - 4mon
consider
line += "-" * len(name)
2
jdnewmil @lemmy.ca - 4mon
Finish putting the + in the line and print it out again:
name = 'World'
line = '+'
for _ in name:
line += '-'
line += '+'
print(line)
print('|' + name + '|')
print(line)
Strings also can be repeated with a * operator:
name = 'World'
line = '+' + '-'*len(name) + '+'
print(line)
print('|' + name + '|')
print(line)
الله in programming
Apparently this code is not good enough can someone help me?
https://lemmy.ml/api/v3/image_proxy?url=https%3A%2F%2Flemmy.world%2Fpictrs%2Fimage%2F74d8b035-cff5-4fb5-96af-884ef182bac6.pngThe second loop basically just creates the same content that’s already in line so it wants you to print that again instead.
I wonder what it would say to
Drop the second loop entirely and just do
print(line + '+')again at the end -lineandlin2contain the exact same string so it's unnecessary to construct it twice.ohhh this is the answer i was looking for
others suggested me some shit like
name = "World" print(f"+{'':-^{len(name)}}+\n|{name}|\n+{'':-^{len(name)}}+")
i was confused AF
consider
Finish putting the + in the line and print it out again:
Strings also can be repeated with a * operator: