+ 2
Having problem
Tell me the problem in it https://code.sololearn.com/cyrv2e3ha7DF/?ref=app
15 Answers
+ 3
I m not sure if it is correct or not.
But taking
input =banana
Output =Aditya
https://code.sololearn.com/cMj4eQ7OrwqL/?ref=app
+ 4
That's is just link to your post ,instead insert your code using insert code option for description,
+ 3
Thanku ✌️
+ 3
Aditya Salabh. 𝕊𝕆𝕌𝕄𝕐𝔸 𝕊𝔸ℍ𝕌
Hello the problem is the wrong indentation done in the for block:
#Your code
for i in range(len(string)):
if string[i] not in v:
s1= s1 +len(string)-i
else:
s2=s2 +len(string)-i
if s1>s2:
print("winner is"+n)
elif s2>s1:
print ("winner is "+b)
else:
print ("draw")
You see from the if everything is badly indented. You change that to:
for i in range(len(string)):
if string[i] not in v:
s1= s1 +len(string)-i
else:
s2=s2 +len(string)-i
if s1>s2:
print("winner is"+n)
elif s2>s1:
print ("winner is "+b)
else:
print ("draw")
To this corrected code here you see that. The problem of indentation is solved and your code will run successfully 😃😃
+ 2
Hello Aditya Salabh
Please share the link only in the description. In the title or tag it is not clickable.
+ 2
What u changed in it....?????
+ 2
There was intention issue in your code.
That only I have corrected.
+ 2
Check the code that I have commented earlier.In that I have mentioned the reason why it gave error.
+ 1
Not getting how to define can anyone make it correct
+ 1
Input :banana
OUTPUT: Aditya
+ 1
Indententation is important
Try to use TAB
def game_nin(string):
s1=0
s2=0
v=str("aeiou")
n=str("aditya")
print(n)
b=str("sweta")
print(b)
for i in range(len(string)):
if string[i] not in v:
s1= s1 +len(string)-i
else:
s2=s2 +len(string)-i
if s1>s2:
print("winner is"+n)
elif s2>s1:
print ("winner is "+b)
else:
print ("draw")
# n=str(input("enter the name:"))
# a=str(input("enter the string:"))
string=str(input())
game_nin(string)
0
✌️✌️👍