Please help me understand this. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Please help me understand this.

text 5="I love programming" text 6="I love science" text 7="I love myself" text =[text5, text6, text7] new=text [1][3] print (h+new+t+p+y)

11th Aug 2018, 6:32 AM
subia
3 Answers
+ 1
Like this it works (removed spaces and added quotes): text5="I love programming" text6="I love science" text7="I love myself" text =[text5, text6, text7] new=text [1][3] print ("h"+new+"t"+"p"+"y") It adds the letters h o t p and y into a single string. The o comes from text6, it is the fourth character. Variable new takes the second word out of the list (That is index 1) and the fourth character out of the word (That is index 3).
11th Aug 2018, 6:48 AM
Paul
Paul - avatar
+ 1
#FIXED text 5="I love programming" text 6="I love science" text 7="I love myself" text =[text5, text6, text7] new=text [1][3] #new = text6[3] #new = "o" print ("h"+new+"t"+"p"+"y") #it prints: h+o+t+p+y: "hotpy"
11th Aug 2018, 7:58 AM
Sousou
Sousou - avatar
0
Wrong variable name *spaces aren't allowed as part of variable names
11th Aug 2018, 6:47 AM
Dlite
Dlite - avatar