TORONTO KIDS COMPUTER CLUB | Wednesday Friday 15:00 Python Practice 20.08.28.
18226
post-template-default,single,single-post,postid-18226,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

Wednesday Friday 15:00 Python Practice 20.08.28.

30 Aug Wednesday Friday 15:00 Python Practice 20.08.28.

Question:
Use input() to take 10 input from user, each item is separated by space. Then try to complete the following task:

    1. Create a list from the input
    2. Delete all repeated elements of the list.
Sample Input 1:
1 2 3 2 1 3 98 98 67

Sample Output 1:
1,2,3,98,67

Sample Input 2:
Kevin Jack Kevin Jack Kevin Jack Kevin Kevin Jack Jack

Sample Output 2:
Kevin,Jack

Hint:
1. You could use split() to convert the input string into a list
2. You could create another list, if the item is not in that list, you can add the new item into that list
3. You could use item in list to check if the item in the list or not
2 Comments
  • Jesse Shi
    Posted at 22:04h, 31 August Reply

    >>> num = “1 2 3 2 1 3 98 98 67”
    >>> n = num.split()
    >>> print(n)
    [‘1’, ‘2’, ‘3’, ‘2’, ‘1’, ‘3’, ’98’, ’98’, ’67’]

  • Jesse Shi
    Posted at 22:31h, 31 August Reply

    >>> name.append(‘Kevin,Jack’)
    >>> print(name)
    [‘Kevin,Jack’]

Post A Comment