Ask Question

Create a list words = ['is', 'NLP', 'fun', '?']. Use a series of assignment statements (e. g. words[1] = words[2]) and a temporary variable tmp to transform this list into the list ['NLP', 'is', 'fun', '!']. Now do the same transformation using tuple assignment.

+1
Answers (1)
  1. 18 March, 21:17
    0
    words = ['is', 'NLP', 'fun', '?']

    tmp = words[1]

    words[1] = words[0]

    words[0] = tmp

    words[3] = '!'

    print (words)

    Explanation:

    - Create the list

    - Assign the new values using tmp variable

    - Print the result

    Since tuples in Python are unchangeable, you cannot transform the list using tuple assignment.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Create a list words = ['is', 'NLP', 'fun', '?']. Use a series of assignment statements (e. g. words[1] = words[2]) and a temporary variable ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers