How can we take input if we cannot use lists and arrays

How can we take input if we cannot use lists and arrays

Hey @bhavikak, first take input integer n, and than use for loopt to take line by line input and than convert it into integer. And than proceed in whatever way you like.

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. :blush:

Hey Vasu, thanks for your reply.

I have written a program with a general logic of this problem, could you please check the same:

n=int(input())
print(n)
for i in range(1,n+1):
x=int(input())
print(x)

for i in range(1,n+1):
for j in range(2,n+1):
if i>j:
print(“False”)
break
else:
print(“True”)
break
break

I am receiving the output in case of increasing sequence but not getting the answer for decreasing sequence. could you please let me know my mistake

I think there is an issue with the for loops, could you please help me with this

Hey @bhavikak, you have taken the input but you have not stored it yet. I think you are struggling with the problem, this is the solution code, try to use pen and paper and understand how it works. If unable to understand feel free to ask us out.

n=int(input())
str=[""]*n
for i in range(n):
    str[i]=int(input())
c=0
while(c<n-1 and str[c]>str[c+1]):
    c=c+1   
while(c<n-1 and str[c]<str[c+1]):
    c=c+1
if(c==n-1):
    print("true")
else:
    print("false") 

Hope this resolved your doubt.
Plz mark it as resolved in my doubts section as well. :blush:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

thanks for your reply.

Can you please tell me the meaning of this statement: str=[""]*n?

Hey @bhavikak, i just created the list, having n elements so that i could replace them. You could do this way also.

n=int(input())
str=[]
for i in range(n):
    str.append(int(input()))