Python Forum
simple string & input problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
simple string & input problem
#6
(Jun-23-2019, 02:38 PM)ichabod801 Wrote:
height = input('What is your height, {}? '.format(name))  # 56 characters
height = input(f'What is your height, {name}? ')          # 48 characters
height = input('What is your height ' + name + ' ')       # 52 characters
f-strings are the easy way. Note that adding another variable to this would add 2 characters plus the variable name to the format and f-string techniques, and 8 characters (4 spaces, 2 plusses, 2 quotes) to the addition technique. So in general, format will be easier than addition as well. And depending on implementation, addition can be less efficient.

now i understand you have really helped me i used the last one and it worked out. Note that I just started learning, and i appreciate the help.
Reply


Messages In This Thread
simple string & input problem - by kungshamji - Jun-23-2019, 11:04 AM
RE: simple string & input problem - by ichabod801 - Jun-23-2019, 11:32 AM
RE: simple string & input problem - by kungshamji - Jun-23-2019, 01:49 PM
RE: simple string & input problem - by perfringo - Jun-23-2019, 02:08 PM
RE: simple string & input problem - by ichabod801 - Jun-23-2019, 02:38 PM
RE: simple string & input problem - by kungshamji - Jun-23-2019, 03:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using string input for boolean tronic72 3 693 Nov-01-2023, 07:48 AM
Last Post: Gribouillis
  problem in using input command akbarza 4 1,129 Oct-19-2023, 03:27 PM
Last Post: popejose
  problem in entering address of a file in input akbarza 0 651 Oct-18-2023, 08:16 AM
Last Post: akbarza
  A simple problem, how best to solve it? SuchUmami 2 720 Sep-01-2023, 05:36 AM
Last Post: Pedroski55
Sad How to split a String from Text Input into 40 char chunks? lastyle 7 1,131 Aug-01-2023, 09:36 AM
Last Post: Pedroski55
  How to solve this simple problem? Check if cvs first element is the same in each row? thesquid 2 1,231 Jun-14-2022, 08:35 PM
Last Post: thesquid
  Convert string to float problem vasik006 8 3,400 Jun-03-2022, 06:41 PM
Last Post: deanhystad
Big Grin General programming question (input string)[ jamie_01 2 1,597 Jan-08-2022, 12:59 AM
Last Post: BashBedlam
  Problem with input after function luilong 10 4,092 Dec-04-2021, 12:16 AM
Last Post: luilong
Big Grin question about simple algorithm to my problem jamie_01 1 1,673 Oct-04-2021, 11:55 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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