0

How to mention something in a print , like we use in ruby #{ } , similary how it can be done in python?

like this , in ruby: number = 2 print ("number is #{number}") Output : number is 2 similarly how to do it in python???

20th Apr 2018, 6:45 PM
Sahil Soni
Sahil Soni - avatar
2 Réponses
+ 1
It's string interpolation: g = "Face" print(f"Troll{g}") #This method doesn't work in SoloLearn:( _______________________________ h = "World" print("Hello %s" %(h)) _______________________________ t = "Awesome" print("SoloLearn is {}".format(t))
20th Apr 2018, 7:44 PM
Alihuseyn Kengerli
Alihuseyn Kengerli - avatar
+ 1
with your example it goes like number = 2 print("number is ", number) or with format print("number is {}".format(number))
20th Apr 2018, 7:48 PM
Markus Kaleton
Markus Kaleton - avatar