Python Forum
Combining two strings together (not concatenation)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Combining two strings together (not concatenation)
#7
Thanks!

That makes many things easier.

I created this piece of code with the zip function:
for char in zip(curr, other):
    if char[0] == '1' and char[1] == '1':
        new = new + '1'
    if char[0] == '0' and char[1] == '0':
        new = new + '0'
    if char[0] == '4' and char[1] != '3':
        new = new + '4'
    if char[1] == '3':
        new = new + '3'
print(new)
It probably could be improved but at least it works.

Thanks,
Dream
Reply


Messages In This Thread
RE: Combining two strings together (not concatenation) - by DreamingInsanity - Mar-29-2019, 04:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries sawtooth500 14 1,442 Apr-24-2024, 01:42 AM
Last Post: sawtooth500
  FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries i sawtooth500 3 2,751 Mar-22-2024, 03:08 AM
Last Post: deanhystad
  Trying to understand strings and lists of strings Konstantin23 2 921 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,907 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  String concatenation in SQL update statement hammer 3 1,663 Feb-24-2022, 08:00 PM
Last Post: hammer
  f string concatenation problem growSeb 3 2,363 Jun-28-2021, 05:00 AM
Last Post: buran
  Concatenation ?? ridgerunnersjw 1 1,809 Sep-26-2020, 07:29 PM
Last Post: deanhystad
  Finding multiple strings between the two same strings Slither 1 2,624 Jun-05-2019, 09:02 PM
Last Post: Yoriz
  Regarding concatenation of a list to a string Kedar 2 22,910 Aug-19-2018, 12:57 PM
Last Post: ichabod801
  lists, strings, and byte strings Skaperen 2 4,340 Mar-02-2018, 02:12 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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