BaşlayınÜcretsiz Başlayın

Making tuples by accident

Tuples are very powerful and useful, and it's super easy to make one by accident. All you have to do is create a variable and follow the assignment with a comma. This becomes an error when you try to use the variable later expecting it to be a string or a number.

You can verify the data type of a variable with the type() function. In this exercise, you'll see for yourself how easy it is to make a tuple by accident.

Bu egzersiz

Data Types in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Create a variable named normal and set it equal to 'simple'.
  • Create a variable named error and set it equal to 'trailing comma',.
  • Print the type of the normal and error variables.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create the normal variable: normal
normal = ____

# Create the mistaken variable: error
error = ____

# Print the types of the variables
print(____)
print(____)
Kodu Düzenle ve Çalıştır