+ 3
happy new year to you, hello friends. Help
I have input 5 1 2 3 4 5 How to write such input in Python in an array And the same ones on the list. For example 5 And after it immediately the number 1 2 3 4 5 I am studying python help me.
8 ответов
+ 5
Here are different 5 Methods that outputs 1 2 3 4 5 or [1, 2, 3, 4, 5]. Maybe you can find here what you are referring to.
https://code.sololearn.com/ca15A8A19A10
+ 3
An example how to handle multiple inputs on the same line. You can use the split() function to convert the input string to a list. The default delimiter is whitespace but you can use another character too.
Note you will probably need to convert the values to numeric type with the int() function, if you want to calculate with them.
https://code.sololearn.com/cw2ywpU2RF0o/?ref=app
+ 3
It's a list comprehension.
+ 1
《 Nicko12 》 thanks 😊
0
《 Nicko12 》 I mean entering 5 after it in an array 1 2 3 4 5
0
《 Nicko12 》 and also, what is the name of this operation [i for i in range(1, num+1)]
0
David Ashton thanks 😊, happy holiday.
0
n = int(input())
lst = [x for x in range(1,n+1)]
print(lst)