Breaking Up String Variables

Basic name assignment

variableName = 'This is a string.'

List assignment

One, Two, Three = [1, 2, 3]

Break up a string into variables

firstLetter, secondLetter, thirdLetter, fourthLetter = 'Bark'
firstLetter
'B'
secondLetter
'a'
thirdLetter
'r'
fourthLetter
'k'

Breaking up a number into seperate variables

firstNumber, secondNumber, thirdNumber, fourthNumber = '9485'
firstLetter
'B'
secondLetter
'a'
thirdLetter
'r'
fourthLetter
'k'

Assign the first letter of 'spam' into varible a, assign all the remaining letters to variable b

a, *b = 'spam'
a
's'
b
['p', 'a', 'm']