python function and .format command | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

python function and .format command

hi please help me understand this code 1.what ".format" do in this in this code ??!! 2.and please tell me what happened in return " resp[1] == 's' "??? def buzz(self, addr, length): resp = self.send_this('+B{}{:0>2x}-'.format(addr, length)) return resp[1] == 's'

20th Sep 2017, 12:38 PM
hossein hayati
hossein hayati - avatar
2 Answers
+ 2
1. .format put variables address and length into a string in formated way. for details see https://pyformat.info 2. it is output of the function. it returns True or False depending on the second character of the string in variable resp
20th Sep 2017, 1:13 PM
yuri
0
ok
14th Oct 2017, 3:04 PM
qadriddin