When the number of inputs of the string and the maximum number of files to be input in the first code is 20,000
num = int(input())
stra = [0]*20000
Define it like this.
for i in range(0,num,1) :
stra[i] = input()
stra.sort()
When I sort the input strings, I get an error because the string '<' not supported between instances of 'int' and 'str' is the same number. How do I declare a list?
string python input
In Python, the list can be used dynamically.
You don't need an initialization like an array.
Do it as below.
num = int(input())
stra = []
for i in range(0,num,1) :
stra.append(input())
stra.sort()
© 2024 OneMinuteCode. All rights reserved.