Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sentence maker help
#1
Okay, so recently I've been trying to make a program that makes very simple sentences. I've made a breakthrough by figuring out that 'if' and 'or' exist. Right now it looks like this:

if random.choice(ss) is 'I':
     if random.choice(an) is 'hate' or 'love':
        print("I " + random.choice(hl) + " " + random.choice(Pn))
That's all fine, but then I added another line in, so now it looks like this:
if random.choice(ss) is 'I':
     if random.choice(an) is 'hate' or 'love':
        print("I " + random.choice(hl) + " " + random.choice(Pn))
     if random.choice(an) is 'killed':
         print("I killed " + random.choice(ka))
Now, it sometimes prints both things, so it'll be like

I love people
I killed god

but sometimes it'll do just the ones from love/hate, which means that it only happens when random.choice(an) = 'killed'. How do I fix this so that only one or the other gets shown? I plan on adding another line for another random.choice(an) and I need to fix the problem so it doesn't keep outputting more than I want it to. Thanks in advance!
Reply


Messages In This Thread
Sentence maker help - by bidoofis - Feb-08-2019, 02:49 AM
RE: Sentence maker help - by ichabod801 - Feb-08-2019, 03:36 AM
RE: Sentence maker help - by bidoofis - Feb-08-2019, 03:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with flowchart maker program bluebouncyball 2 733 Aug-08-2023, 10:25 PM
Last Post: deanhystad
  Label Maker FPDF, Reportlab jamesaarr 1 2,602 Aug-09-2021, 11:57 PM
Last Post: Pedroski55
  while sentence kimyyya 3 2,905 Mar-20-2021, 06:00 AM
Last Post: Pedroski55
  List / arrays putting in sentence Kurta 3 2,514 Dec-25-2020, 11:29 AM
Last Post: Larz60+
  How to make a telegram bot respond to the specific word in a sentence? Metodolog 2 6,271 Dec-22-2020, 07:30 AM
Last Post: martabassof
  How to match partial sentence in long sentence Mekala 1 1,486 Jul-22-2020, 02:21 PM
Last Post: perfringo
  Remove a sentence if it contains a word. lokhtar 6 5,773 Feb-11-2020, 04:43 PM
Last Post: stullis
  Regex Help for clubbing similar sentence segments regstuff 3 2,113 Nov-20-2019, 06:46 AM
Last Post: perfringo
  how to get all the possible permutation and combination of a sentence in python sodmzs 1 4,121 Jun-13-2019, 07:02 AM
Last Post: perfringo
  wont print last sentence.. mitmit293 2 2,323 Jan-27-2019, 05:38 PM
Last Post: aakashjha001

Forum Jump:

User Panel Messages

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