Python Forum
i need help with this simple code
Thread Rating:
  • 3 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
i need help with this simple code
#1
I don't know what is wrong with this code can someone fix it for me or help me fix it?

name = "" 
print("What is your name")
input(name)
if name == "Amar" : 
    print("Hi Amar") 
    
    elif name == "Brandy" :
        print("Ahoy Brandy :D")
        
        else : 
            print("Hello" + name)
            
Reply
#2
your code from elif and thereafter has to be dedented back 4 spaces
Recommended Tutorials:
Reply
#3
The error message probably would have helped you figure the indentation problem out.
Reply
#4
I still got errors this is what I'm trying to do

In this program, you must ask the user:
# "What is your name?"
#
# And then respond by printing out a personalized greeting.


# GENERAL RULE
#
# For a person named Maria, respond by printing:
# Hello Maria
#
# For a person named Wally, respond by printing:
# Hello Wally
#
# ...etc.
#
# In general, for a person named <NAME>, respond by printing:
# Hello <NAME>


# SPECIAL NAMES
#
# Two people are special: Amar and Brandy.
# These two names should receive unique greetings (and smiley faces)
#
# For a person named Amar, respond by saying:
# Hi Amar :)
#
# For a person named Brandy, respond by saying:
# Ahoy Brandy :D
Reply
#5
Quote:hi thanks for the respond. however it does't work I still got errors.

this is what i'm trying to do

In this program, you must ask the user:
# "What is your name?"
#
# And then respond by printing out a personalized greeting.

# GENERAL RULE
#
# For a person named Maria, respond by printing:
# Hello Maria
#
# For a person named Wally, respond by printing:
# Hello Wally
#
# ...etc.
#
# In general, for a person named <NAME>, respond by printing:
# Hello <NAME>

# SPECIAL NAMES
#
# Two people are special: Amar and Brandy. 
# These two names should receive unique greetings (and smiley faces)
#
# For a person named Amar, respond by saying:
# Hi Amar :)
#
# For a person named Brandy, respond by saying:
# Ahoy Brandy :D
Please dont PM members that respond. Post in the forums.
There of course more errors. Is this code fix homework?
Recommended Tutorials:
Reply
#6
That looks like homework. Which is fine, but there's a forum for that.
Reply
#7
this is a task I have for today. I have less than a hour to summit it. please help. I know c#, c++, and java but python it's just harder. this is an assignment to get into a class. please I cannot lose this opportunity
Reply
#8
Your if structure block are really messed up
http://python-forum.io/Thread-Indentation-basic


Quote:name = "" 
print("What is your name")
input(name)
What else do you expect the variable name to be?
Recommended Tutorials:
Reply
#9
I don't understand the question. i''m use to program in c#, C++ and Java. this is too confuse to me
Reply
#10
(Oct-18-2016, 03:10 AM)josephb401 Wrote: i''m use to program in c#, C++ and Java. this is too confuse to me
If you understand those languages, then you should understand blocks of code too. The tutorial i linked should give you enough information to fix the indentation code.

input() returns your input, it does not do it in place
ie
name = input()
http://anh.cs.luc.edu/python/hands-on/3....ml/io.html
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  First Day using Python. NEED Simple Math CODE HELP! Jesseluke 4 1,320 Jan-13-2023, 01:04 PM
Last Post: jefsummers
  my simple code wont work! help! simon12323121 2 1,989 Sep-05-2021, 09:06 AM
Last Post: naughtyCat
  Can anyone please help with very simple code bee 6 4,813 Sep-29-2017, 02:26 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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