- 1
PLEASE HELP WITH THIS.
Consider the string BANANA and print the string in the following format: B B A B A N B A N A B A N A N B A N A N A Input Format: Enter the number of lines of the format to be printed : n (if n=4) Output Format : B B A B A N B A N A Sample Input: 6 Sample Output: B B A B A N B A N A B A N A N B A N A N A MY CODE: a=input() n=input() for i in range(0,n): for j in range(0, i+1): if (n==4): print(a[j],end=" ") print()
4 Respostas
+ 4
#try this
a=input()
n=int(input())
for i in range(0,n):
for j in range(0, i+1):
print(a[j],end=" ")
print()
+ 3
b="B a n a n a".upper()
for i in range(len(b)):
print(b[0: i+1])
+ 1
Input() returns a string, you must use int() to convert it to a number:
n= int( input() )
Also you have a logic problem, what is that if supposed to do?
0
Check this out:
https://code.sololearn.com/c0KEsMULXAec/?ref=app