Python Forum
Split string at specific number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split string at specific number
#3
Uh, yes.
Here it is.

for i in range(0, len(pi)):
	x = int(pi[i])
	if  0 < x < 3:
		y = int(pi[i+1])
		if x == 1:
			char = int(pi[i] + pi[i+1]) + 65
			chars.append(chr(char))
		if x == 2 and y < 6:
			char = int(pi[i] + pi[i+1]) + 65
			chars.append(chr(char))
print(chars)
The problem is, that it iterates through the number, in this case Pi, but i can't jump twice if there is a number with two decimals which is contained in the alphabet.
Like 14. I can't jump twice to 15, so 4 is also counted as a character, but that not the goal.
Just considered whether a while loop could help me, because I can set the steps each round manually.

What do you think? Or is there any other more effective solution?

Yours Sincerely,
TimeMen
Reply


Messages In This Thread
Split string at specific number - by TimeMen - Apr-28-2018, 08:47 PM
RE: Split string at specific number - by micseydel - Apr-29-2018, 04:57 AM
RE: Split string at specific number - by TimeMen - Apr-29-2018, 07:13 AM
RE: Split string at specific number - by micseydel - Apr-30-2018, 02:37 AM
RE: Split string at specific number - by buran - Apr-30-2018, 08:42 AM
RE: Split string at specific number - by killerrex - Apr-30-2018, 09:32 AM
RE: Split string at specific number - by wavic - May-01-2018, 07:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  doing string split with 2 or more split characters Skaperen 22 3,064 Aug-13-2023, 01:57 AM
Last Post: Skaperen
Sad How to split a String from Text Input into 40 char chunks? lastyle 7 1,393 Aug-01-2023, 09:36 AM
Last Post: Pedroski55
Question Extracting Version Number from a String britesc 2 1,285 May-31-2023, 10:20 AM
Last Post: britesc
  [split] Parse Nested JSON String in Python mmm07 4 1,725 Mar-28-2023, 06:07 PM
Last Post: snippsat
  Split string using variable found in a list japo85 2 1,450 Jul-11-2022, 08:52 AM
Last Post: japo85
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 5,167 Jul-01-2022, 01:23 PM
Last Post: deanhystad
  Split a number to list and list sum must be number sunny9495 5 2,660 Apr-28-2022, 09:32 AM
Last Post: Dexty
  Split string knob 2 1,985 Nov-19-2021, 10:27 AM
Last Post: ghoul
Question [SOLVED] Delete specific characters from string lines EnfantNicolas 4 2,418 Oct-21-2021, 11:28 AM
Last Post: EnfantNicolas
  Remove Specific Columns when the number of columns is greater than a specific value CuriousOne 0 1,407 Sep-09-2021, 09:17 PM
Last Post: CuriousOne

Forum Jump:

User Panel Messages

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