Python Forum
Trying to make two different strings from the same root
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to make two different strings from the same root
#1
import random

a = input()

# This is where I'm stuck
mark1 = ["*", "__", "~~"]
mark2 = ["*", "__", "~~"][:-mark1]
#I don't know the correct intonation to replace "[:-mark1]"
#This gives an error due to it not being an actual command

g = random.randint(1,2)
if g == 1:
  if mark1 == "*":
    mark1 = "*"*random.randint(1,3)
    e = random.choice(mark1) + random.choice(mark2)
    f = e[::-1]
    print(e + a + f)
  else:
    e = random.choice(mark1)
    if mark1 == "*":
      e = "*"*random.randint(1,3)
      print(e + a + e)
All I need to be able to do is to give a string which will randomly surround text "a" with either *, __ or ~~. In addition, I need it to (50% of the time) be able to add these together with the second reversed: eg. __*Hello*__

Any help would be much appreciated, I'm still a new coder trying to practice some strings
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand strings and lists of strings Konstantin23 2 757 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,757 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  Finding multiple strings between the two same strings Slither 1 2,514 Jun-05-2019, 09:02 PM
Last Post: Yoriz
  unable to pass a input after changing the user from root to non root using python avinash 3 3,179 Apr-08-2019, 10:05 AM
Last Post: avinash
  lists, strings, and byte strings Skaperen 2 4,215 Mar-02-2018, 02:12 AM
Last Post: Skaperen
  Concatinating two strings to make a variable bencouve 5 4,967 Jun-21-2017, 10:06 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

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