Python Forum
from string to list to string.
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
from string to list to string.
#5
split it up into many white-space separated words (however many there are), and take the last item [-1] as the age and slice all but the last [:-1] one as the name.  suggestion: use a variable name other than name for the input before the name is sliced out.  extra points: check if the last one is a valid age (is '56.1' a valid age?)  more points: take ages like '27 years and 3 months'.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
from string to list to string. - by mcmxl22 - Feb-04-2017, 03:57 AM
RE: from string to list to string. - by Larz60+ - Feb-04-2017, 04:11 AM
RE: from string to list to string. - by snippsat - Feb-04-2017, 05:11 AM
RE: from string to list to string. - by mcmxl22 - Feb-04-2017, 05:54 AM
RE: from string to list to string. - by Skaperen - Feb-04-2017, 07:18 AM
RE: from string to list to string. - by snippsat - Feb-04-2017, 08:58 AM
RE: from string to list to string. - by wavic - Feb-04-2017, 01:26 PM
RE: from string to list to string. - by snippsat - Feb-04-2017, 06:30 PM
RE: from string to list to string. - by nilamo - Feb-04-2017, 11:13 PM
RE: from string to list to string. - by Larz60+ - Feb-05-2017, 01:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: string indices must be integers, not 'str' LEMA 2 152 Jun-12-2024, 09:32 PM
Last Post: LEMA
  Formatting DateTime string and and converting it from AM/PM to 24 hours tester_V 2 190 Jun-08-2024, 05:16 PM
Last Post: tester_V
  Use or raw string on regular expressions Zaya_pool 5 486 May-09-2024, 06:10 PM
Last Post: Zaya_pool
  How do I parse the string? anna17 4 524 Apr-10-2024, 10:26 AM
Last Post: DeaD_EyE
  remove gilberishs from a "string" kucingkembar 2 393 Mar-15-2024, 08:51 AM
Last Post: kucingkembar
  Matching string from a file tester_V 5 615 Mar-05-2024, 05:46 AM
Last Post: Danishhafeez
  Python3 string slicing Luchano55 4 752 Feb-17-2024, 09:40 AM
Last Post: Pedroski55
  Retrieve word from string knob 4 633 Jan-22-2024, 06:40 PM
Last Post: Pedroski55
  Writing a Linear Search algorithm - malformed string representation Drone4four 10 1,258 Jan-10-2024, 08:39 AM
Last Post: gulshan212
  Virtual Env changing mysql connection string in python Fredesetes 0 464 Dec-20-2023, 04:06 PM
Last Post: Fredesetes

Forum Jump:

User Panel Messages

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