Python Forum
i've got these very simple homework
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
i've got these very simple homework
#5
thank you both very much.

the first option is what i was needed

:)

ok, i've tried to write it but i get an error. can you tell me why?

  File "fortune_cookie.py", line 11
    elif cookie == 2:
       ^
SyntaxError: invalid syntax
# Write a program that simulates a fortune cookie. The program
# should display one of five unique fortunes, at random, each
# time it’s run.

import random

cookie = random.randint(1, 5)
if cookie == 1:
	print("For hate is never conquered by hate. Hate is conquered by love."
	
elif cookie == 2:
	print("Your worst enemy has a crush on you!")
	
elif cookie == 3:
	print("You will make many changes before settling down happily.")
	
elif cookie == 4:
	print("If you have something worth fighting for, then fight for it.")
	
elif cookie == 5:
	print("In music, one must think with his heart and feel with his brain.")

input("\n\nPress the enter key to exit.")
i was sure it would work
Reply


Messages In This Thread
i've got these very simple homework - by HakolYahol - Aug-07-2018, 07:43 AM
RE: i've got these very simple homework - by wavic - Aug-07-2018, 08:31 AM
RE: i've got these very simple homework - by woooee - Aug-07-2018, 05:15 PM
RE: i've got these very simple homework - by buran - Aug-07-2018, 05:23 PM
RE: i've got these very simple homework - by HakolYahol - Aug-08-2018, 10:16 AM
RE: i've got these very simple homework - by buran - Aug-08-2018, 11:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Where can I get loooads of simple homework questions for kids? omar 3 1,129 Yesterday, 11:43 AM
Last Post: kiddoo
  [TkInter]Simple Python Homework zaji_123 4 4,196 Jan-01-2021, 07:09 PM
Last Post: EliesBe
  Please help. Simple homework Asm0deus314 3 3,536 Feb-02-2020, 07:03 PM
Last Post: michael1789
  Homework Help - Simple Grading System Segovia 7 8,053 Jul-24-2018, 10:55 PM
Last Post: Segovia

Forum Jump:

User Panel Messages

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