Python Forum
string with integer variable within
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
string with integer variable within
#9
(Mar-12-2018, 02:46 AM)Larz60+ Wrote: try the following:
    lcd.clear()
    msg = 'Indoor: {}\nOutdoor: {}'.format(indoortemp, outdoortemp)
    lcd.message(msg)
Note that there are no quotes around msg. That's because it is a variable.

you should be able to do it this way as well
    lcd.clear()
    lcd.message('Indoor: {}\nOutdoor: {}'.format(indoortemp, outdoortemp))

That works! Very grateful for your help! Thank you! I'll see if I can do some reading on what exactly is happening there. Ive never used .format before.
Reply


Messages In This Thread
string with integer variable within - by Andy1845c - Mar-11-2018, 10:05 PM
RE: string with integer variable within - by Andy1845c - Mar-12-2018, 09:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Replacing String Variable with a new String Name kevv11 2 1,800 Jul-29-2023, 12:03 PM
Last Post: snippsat
  Need help on how to include single quotes on data of variable string hani_hms 5 7,901 Jan-10-2023, 11:26 AM
Last Post: codinglearner
  python r string for variable mg24 3 7,395 Oct-28-2022, 04:19 AM
Last Post: deanhystad
  USE string data as a variable NAME rokorps 1 1,609 Sep-30-2022, 01:08 PM
Last Post: deanhystad
  Removing Space between variable and string in Python coder_sw99 6 11,170 Aug-23-2022, 01:15 PM
Last Post: louries
  Remove a space between a string and variable in print sie 5 3,107 Jul-27-2022, 02:36 PM
Last Post: deanhystad
  Split string using variable found in a list japo85 2 2,306 Jul-11-2022, 08:52 AM
Last Post: japo85
  Can you print a string variable to printer hammer 2 2,936 Apr-30-2022, 11:48 PM
Last Post: hammer
Question How to convert string to variable? chatguy 5 5,279 Apr-12-2022, 08:31 PM
Last Post: buran
  Question about change hex string to integer sting in the list (python 2.7) lzfneu 1 3,422 May-24-2021, 08:48 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020