Hello every one
I got a little problem with my code and I don't know how to fix it
.
Is a homework from python, I have to write a program and make a longest increasing subsequence.
I let you here the homework:
LONGEST INCREASING SUB-SEQUENCE
Write a program, which reads a sequence of integers (in one string, the numbers are separated by
spaces). The program then prints its longest increasing sub-sequence. If there are several increasing
sub-sequences of the same length, the program prints the first one. A sequence is increasing when
𝑎𝑎𝑖𝑖 < 𝑎𝑎𝑖𝑖+1 for each 𝑖𝑖.
Examples:
Input: 1 7 8 3 4 6 8 9 0 5 1 2 3
Output: 3 4 6 8 9
Input: 5 4 2 3 4 9 9 9 -8 -5 -3 -2 -1
Output: -8 -5 -3 -2 -1
Input: -3 -2 8
Output: -3 -2 8
Input: 5 4 3 2 1 0
Output: 5
Currently, the code I have written works perfectly, but I need the array to be written by the user and not pre-written in the code (2nd line of the code "arr = [1,2,3,4,5,6]). I need that this list is written by the user at the time of running the program.
P.S.: I have tried changing the given array by:
.
Here is the code I have written now:

I got a little problem with my code and I don't know how to fix it

Is a homework from python, I have to write a program and make a longest increasing subsequence.
I let you here the homework:
LONGEST INCREASING SUB-SEQUENCE
Write a program, which reads a sequence of integers (in one string, the numbers are separated by
spaces). The program then prints its longest increasing sub-sequence. If there are several increasing
sub-sequences of the same length, the program prints the first one. A sequence is increasing when
𝑎𝑎𝑖𝑖 < 𝑎𝑎𝑖𝑖+1 for each 𝑖𝑖.
Examples:
Input: 1 7 8 3 4 6 8 9 0 5 1 2 3
Output: 3 4 6 8 9
Input: 5 4 2 3 4 9 9 9 -8 -5 -3 -2 -1
Output: -8 -5 -3 -2 -1
Input: -3 -2 8
Output: -3 -2 8
Input: 5 4 3 2 1 0
Output: 5
Currently, the code I have written works perfectly, but I need the array to be written by the user and not pre-written in the code (2nd line of the code "arr = [1,2,3,4,5,6]). I need that this list is written by the user at the time of running the program.
P.S.: I have tried changing the given array by:
arr = input ("Write enter whole number separated by spaces:") arr = arr.split ("")But it doesn't work with negative numbers

Here is the code I have written now:
# Given list arr = [5,4,2,3,4,9,9,9,-8,-5,-3,-2,-1] # Storing array length and initialize variable l = len(arr) i = 0 # Difine the array maxium max = 1 ###Initialize the program### # Define varialbes to work s_counting = 0 end_counting = 0 bests_counting = 0 bestend_counting = 0 # While loop - Increment end anytime we found a longer array; update the max; update variables anytime we found a longer array. while i<l: if i+1 < l and arr[i+1]>arr[i]: end_counting = end_counting + 1 if (end_counting-s_counting+1) > max: max = (end_counting - s_counting + 1) bests_counting = s_counting bestend_counting = end_counting # Reset the countings else: s_counting = i+1 end_counting = i+1 i = i + 1 print (arr[bests_counting:bestend_counting+1])Thank you very much for your help

Larz60+ write Feb-28-2021, 06:31 PM:
Please do not create duplicate posts, we read all forums.
Please do not create duplicate posts, we read all forums.