0
n=[int(input()) for x in range(int(input()))]

Here is part of my code I need a function that tells if all the imported numbers are the same except the number that tells how many numbers there will be.

Here is example of input

3
1
1
1

I need to tell if 1=1=1 3 means how much elements will be there. I have tried puting it in for loop n[i]+n[i+1] and n[i]+n[i] and it didnt do anything or was error

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
TurtleSam
  • 29
  • 5

2 Answers2

2

IIUC, you can simply check len(set(n))==1:

For example:

if len(set(n))==1:
    print("All elements are the same")
else:
    print("All elements are not the same")

True implies all numbers are the same.

not_speshal
  • 22,093
  • 2
  • 15
  • 30
0

You can also do it like this

n = int(input())
numlist =[int(input()) for x in range(n)] 
if (numlist[0])*n == sum(numlist):
Python learner
  • 1,159
  • 1
  • 8
  • 20