+ 2
What wrong with this code. Please help?
6 Respuestas
+ 6
Check the last line indentation
,It should have same indentation like the previous line,
n[i]=="solo"
print (i)
+ 4
Thanks u BroFar,MICAEL and Abhay for ur help.
+ 3
Nsubuga Sulaiman here is basically what you have to do as you have to create a int to str environment in order to get to print "solo" based on a number being dividable by 3 with a zero remainder
https://code.sololearn.com/cGa158i7er4V/?ref=app
+ 3
n=int(input())
for i in range(1,n,2):
if i%3==0:
print(i,': solo')
+ 1
what is wrong? first you make a INT an a input for it, next you take him like a ARRAY, and so on.
Finally you compare an element of the "array"(is a number on this case) like a string, you don't do any cast for reorder, your input is wrong since int(input()).
You must learn how to get input for an array and his declaration, but this case is input of an array for strings, buts sems that are 2 dimensional, like one piece string an another int, a pair.
if you dont wanna have many problems i suggest use two diferent array with the same size of elements. Good luck.
sory for bad english.
+ 1
Make sure you indent the code properly, with a fixed indention space like this:
n=int(input())
for i in range(1,n,2):
if n[i]%3==0:
n[i]="solo"
print(i)
And the == operator checks whether the two values and types match. If you want to set n[i] to "solo", use the = operator.