I
I
igoodmood2015-10-31 20:24:14
Python
igoodmood, 2015-10-31 20:24:14

How do you define three variables in one line?

How to write three words in one line, separated by a space, that they were designated as the values ​​of three variables? For example, Apple Tomato Lemon , the value of the first variable is Apple , the value of the second variable is Tomato , the value of the third variable is Lemon .

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nirvimel, 2015-10-31
@igoodmood

s = raw_input('Enter 3 words')
word1, word2, word3 = (s.split() + [''] * 3)[:3]
print  word3, word2, word1

A
Alexander Pupkin, 2015-10-31
@sakrab

a,b,c = Apple,Tomato,Lemon
or

a = "Apple Tomato Lemon"
a[0] = Apple
a[2] = Tomato
a[4] = Lemon

Maybe so?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question