Dremendo Tag Line

Input 10 numbers in integer array and check all numbers are same or not in Python

Arrays - Question 2

In this question, we will see how to input 10 numbers in integer array and check whether all numbers in it are same or not in Python programming. To know more about arrays click on the arrays lesson.

Q2) Write a program in Python to input 10 numbers in integer array and check whether all numbers in it are same or not.

Program

from array import *

c=0
a=array('i',[])

print('Enter 10 numbers')
for i in range(10):
    a.append(int(input()))

for i in range(10):
    if a[0]==a[i]:
        c=c+1

if c==10:
    print('All numbers are same')
else:
    print('All numbers are not same')

Output

Enter 10 numbers
2
2
2
2
2
2
2
2
2
2
All numbers are same
video-poster