Python Forum
[split] Problem with integers and strings
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] Problem with integers and strings
#4
A better way is to use string formatting,then there is no need to convert to string or use of ,+ everywhere.
>>> city = 'Oslo'
>>> description = 'Windy'
>>> temperature = 25
>>> print('{} is currently {} and temperature is {} F'.format(city, description, temperature))
Oslo is currently Windy and temperature is 25 F
Even better in 3.6 we got f-string.
>>> print(f'{city} is currently {description} and temperature is {temperature} F')
Oslo is currently Windy and temperature is 25 F
Reply


Messages In This Thread
RE: [split] Problem with integers and strings - by snippsat - Jan-05-2018, 02:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand strings and lists of strings Konstantin23 2 779 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  problem in using int() with a list of strings akbarza 4 721 Jul-19-2023, 06:46 PM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,782 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  Reading integers from a file; the problem may be the newline characters JRWoodwardMSW 2 1,981 Jul-14-2020, 02:27 AM
Last Post: bowlofred
  Problem with replacing strings donnertrud 3 2,150 May-22-2020, 04:06 PM
Last Post: donnertrud
  [split] Python Class Problem astral_travel 12 5,027 Apr-29-2020, 07:13 PM
Last Post: michael1789
  Split a long string into other strings with no delimiters/characters krewlaz 4 2,805 Nov-15-2019, 02:48 PM
Last Post: ichabod801
  problem with for loop using integers python_germ 5 3,010 Aug-31-2019, 11:42 AM
Last Post: jefsummers
  re.split multiple delimiters problem gw1500se 2 3,637 Jun-24-2019, 02:43 PM
Last Post: gw1500se
  Finding multiple strings between the two same strings Slither 1 2,534 Jun-05-2019, 09:02 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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