![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Sep 2009
Posts: 1
OS: xp
|
Python question
Hi tech support forum,
I have a Python question I cannot solve: Write a function called rand_goodbye(name) that returns (not prints!) a string that says goodbye, where the goodbye phrase is chosen at random from these three possibilities: * Goodbye name * See ya' later name * name: stay cool! Any help would be greatly appreciated otherwise I think my brain might explode ![]() thanks-- |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Visitor, Security Team
Join Date: Mar 2005
Posts: 18
OS: XP Pro SP3, Vista Ultimate SP2, Windows 7 RC
|
Re: Python question
Hi nobody_,
Did you ever get this figured out? I'm just in the process of learning Python myself so thought I'd see what I could come up with. I whipped this up quick. Again, I'm new at this so there are probably better, more syntactically correct, ways of doing it. But it works! Code:
import random
def rand_goodbye(name):
PHRASES = ["Goodbye", "See ya' later", "Stay cool"]
the_phrase = random.choice(PHRASES)
return the_phrase + " " + name
greeting = rand_goodbye("Bob")
print greeting
|
|
|
|
![]() |
| Thread Tools | |
|
|