How to know the errors in my code on hacker blocks

bhaiyya my codes on hacker blocks practice questions are constantly giving errors.

How do i correct them.

iI have submitted my answers.

Hey @surbhi11, can you share the errors with me ?..I will be able to help you if I can see those errors ?

Thanks ! :slightly_smiling_face:

question 10 days of code(practice questions)-piyush and magical park

print (“enter number of rows”)
n=int(input())
print(“enter number of colums”)
m=int(input())
print(“enter minimum strength to be successful”)
k=int(input())
print(“enter the initial strength”)
s=int(input())
a=[]

for a in range(1,n):
for b in range(1,m):
c=input()
if c==".":
if b==m:
s=s-2
b=1
a=a+1
else:
s=s-3
b=b+1
else if c=="*":
if b==m:
s=s+5
b=1
a=a+1
else:
s=s+4
b=b+1
else if c=="#":
b=1
a=a+1

if s>=5:
print(“yes”)
print(s)
else:
print(“no”)

error showing-
File “script.py”, line 16
s=s-2
^
TabError: inconsistent use of tabs and spaces in indentation

i have tried many different variations but it is always giving an error

practice questions(hacker blocks)-10 days of code-gcd

code is-
print (“enter the 2 numbers separated by a line”)
a=int(input())
b=int(input())
c=int(a/2)
d=int(b/2)
t=1
k=1
l=1
for i in range(0,c):
if a%i==0:
k=i
for j in range(0,d):
if b%j==0:
l=j
if l==k:
if l>t:
t=l
print(t)

error showing-
File “script.py”, line 15
if l==k:
^
TabError: inconsistent use of tabs and spaces in indentation

practice-15 days competitive challenge-369 numbers

code-

print (“enter number”)
m=int(input())

a=str(m)
count3=0
count6=0
count9=0
n=len(a)
for i in range(0,n-1):
if a[i]==3:
count3=count3+1
else:
if a[i]==6:
count6=count6+1
else:
if a[i]==9:
count9=count9+1

if count3>0:
if count3==count6==count9:
print(“number is a 369 number”)

Error-

no error but pgm is not running as required(right now I have donefor only 1 number)

today’s code byte(17 sep)-arrays-Is Array Mirror Inverse

code-

print (“enter number of elements0”)
r=int(input())
a=[]
for i in range(0,r-1):
a[i]=int(input())
t=0
for j in range(1,r):
if a[j-1]!=a[-j]:
t=1

if t==0:
print(“true”)

else:
print(“false”)

error-
Traceback (most recent call last):
File “script.py”, line 5, in
a[i]=int(input())
IndexError: list assignment index out of range

daily code-IPL ticket 2020

Code-

print(“enter the number of times you want to evaluate the number of tickets”)
n=int(input())
for i in range(1,n):
print(“enter 2 numbers a and b separated by space where a is greater than or equal to 1 and b is less than or equal to 10^9 and 10^6>|a-b|>0”)
a=int(input())
b=int(input())
t=0
for j in range(a,b):
for k in range(2,j) if kk==j:
if k
k==j:
return
else:
t++

    print(k)    

error-
File “script.py”, line 9
for k in range(2,j): if k*k==j:
^
SyntaxError: invalid syntax

Hey @surbhi11, I am really sorry but I cannot understand the code on text without any indentation. Do upload the python files or maybe .ipynb notebook on google drive and share the link here. It is very difficult to understand the codes in this way.

I hope you understand ! :+1:
Happy coding ! :slightly_smiling_face:

hello bhaiyya-link for google drive is-
https://drive.google.com/drive/folders/1FKV6Mk-vm3bkudjakEXaz917Vr491kB3

bhaiyya whats ur mail id

Okay so in this program you have compared a string datatype with int datatype. Kindly try to run this code :

print ("enter number")
m=int(input())

a=str(m)
count3=0
count6=0
count9=0
n=len(a)
for i in range(0,n):
    if a[i]=='3':
		      count3=count3+1
    else: 
	     if a[i]=='6':
		      count6=count6+1
	     else: 
	          if a[i]=='9':
		           count9=count9+1

if count3>0:
	if count3==count6==count9:
		print("number is a 369 number")		

I hope this works correct ! :blush:

Hey @surbhi11, in this program given below :

print ("enter number of elements0")
r=int(input())
a=[]
for i in range(0,r-1):
	  a[i]=int(input())
	 
t=0
for j in range(1,r):
	if a[j-1]!=a[-j]:
		t=1


if t==0:
	print("true")

else:
	print("false")		

you are trying to create an array in python, which is not correct. Python supports lists and it’s size cannot be decided before running the code. So I would say use a while loop to take an input for as much number of times you want and keep appending that input to a list inside the while loop. In this way once the while loop ends, you will have a list with desired no. of elements ! :slightly_smiling_face:

In the program given below there were many errors which I have corrected. Please have a look at the below code :

print("enter the number of times you want to evaluate the number of tickets")
n=int(input())
for i in range(1,n):
        print("enter 2 numbers a and b separated by space where a is greater than or equal to 1 and b is less than or equal to 10^9 and 10^6>|a-b|>0")
        a=int(input())
        b=int(input())
        t=0
        for j in range(a,b):
          for k in range(2,j):                                                    
            if k*k==j:
              break
            else:
              t = t+1
                                 
        print(k) 

I hope this helps ! :slight_smile:
Happy Learning ! :slightly_smiling_face:

This error is coming because you have not correctly indented your python code. For example instead of this :

if b==m:
s=s-2
b=1
a=a+1

Please replace with properly indented code like :

if b==m:
   s=s-2
   b=1
   a=a+1

I hope this resolves your error atleast ! :slightly_smiling_face:

bhaiyya for 1 integer this works well but when i try to implement for more numbers it is continuously showing indentation error
outer indentation error is an error showing continuously in many of my codes

my new code is in same drtive as last_369

sorry bhaiyya as complete_369

bhaiyya for ipl ticket even after correction (your code) it is not giving the desired output

bhaiyya i have tried but it is still showing some indentation error

in file second_piyush_park in same folder on google drive

bhaiyya i have shared updated code for gcd problem in same location as second_gcd.
It is still showing indentation error

Hey @surbhi11, you are not following the indentations rules and hence that’s why the errors are coming again and again.
Please have a look below :

Why have you left a blank space before q=int(b) ?..Every line of code should be properly indented.

I hope this helps !

Hey @surbhi11, I have not corrected your concept. I have just removed the error u were facing. Try to work on the logic and get correct output by working on the concept.

Thanks !