I want to apply for loop in msg variable in python. there is two variables called names & car_no(from sql queries am getting this).
Type of variable:
car_no = <class 'int'>
names = <class 'str'>
input sample: names & car_no
jhon
198
pig
144
carlet
36
Mona
144
rahul
510
like that 100 names and car_no is there, want to iterate all this names and car_no in msg.(that msg is for send mail to recipents(HTML format))
Required output is :
<html>
<head></head>
<body>
<p>Dear jhon</p>
<p>your bday list:</br>
jhon - 199</br>
pig - 144</br>
carlet -36</br>
mona - 144</br>
rahul - 510</br
<p>
Thanks</br>
</p>
</body>
</html>
I want to apply for loop on this two variable for iterate it in other variable called msg(its html quote)
msg = f'''<html>
<head></head>
<body>
<p>Dear jhon</p>
<p>your bday list:</br>
\t{str(names)} -\t{str(car_no)}</br>
<p>
Thanks</br>
</p>
</body>
</html>'''
I tried:
for query in _queries:
# print(query)
cur.execute(query)
fetch= cur.fetchone().items()
names = list(fetch)[0][0]
car_no= list(fetch)[0][1]
print("names:", type(names))
print("car_no:", type(car_no))
# for k, v in fetch.items():
# print(k,v)
for n in names:
for v in range(car_no):
message = f'''<html>
<head></head>
<body>
<p>Dear jhon</p>
<p>your bday list:</br>
\t{str(names)} -\t{str(car_no)}</br>
<p>
Thanks</br>
</p>
</body>
</html>'''
But its not iterating well, its having 100 records and i want all names and car_no in one msg. can you guys please guide me.
Thanks in Advance