Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Beginner Code
#6
(Mar-18-2019, 08:25 AM)Yoriz Wrote: A single quote is ok when wrapped inside double quotes.

Not always true, get a glance underneath.
# ------- input-output.py -----------
friendName = input("Hey bud. What's your name?")
eyeColor = input("What color are your eyes, " + friendName)
hairColor = input("What color is your hair?")
friendAge = input("Awesome! Mine too. How old are you?")
# Let's see when this chap was born...
int_friendAge = int(friendAge)
int_yearBorn = 2019 - (int_friendAge)
yearBorn = str(int_yearBorn)
print("That means you were born in " + yearBorn)
# ---------- Running under python2 [ERROR]----------
#C:\Training>py -2.7 input-output.py
#Hey bud. What's your name?bill
#Traceback (most recent call last):
#  File "input-output.py", line 2, in <module>
#    friendName = input("Hey bud. What's your name?")
#  File "<string>", line 1, in <module>
#NameError: name 'bill' is not defined
#
# ---------- Running under python3 [WORKS]----------
#C:\Training>python input-output.py
#Hey bud. What's your name?bill
#What color are your eyes, billblue
#What color is your hair?black
#Awesome! Mine too. How old are you?15
#That means you were born in 2004
#------------------------------------------------------
Reply


Messages In This Thread
Beginner Code - by bh3282 - Mar-18-2019, 04:30 AM
RE: Beginner Code - by samsonite - Mar-18-2019, 05:42 AM
RE: Beginner Code - by woooee - Mar-18-2019, 06:46 AM
RE: Beginner Code - by samsonite - Mar-18-2019, 07:25 AM
RE: Beginner Code - by Yoriz - Mar-18-2019, 08:25 AM
RE: Beginner Code - by samsonite - Mar-18-2019, 10:25 AM
RE: Beginner Code - by buran - Mar-18-2019, 11:03 AM
RE: Beginner Code - by samsonite - Mar-18-2019, 11:26 AM
RE: Beginner Code - by buran - Mar-18-2019, 11:36 AM
RE: Beginner Code - by samsonite - Mar-18-2019, 03:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner: Code not work when longer list raiviscoding 2 850 May-19-2023, 11:19 AM
Last Post: deanhystad
  Code not reading http link from .txt file (Beginner level) plarrip 3 2,452 Dec-17-2020, 11:33 PM
Last Post: bowlofred
  Beginner: I need help understanding few lines of a code. hop_090 1 1,715 Sep-07-2020, 04:02 PM
Last Post: Larz60+
  Beginner Code, how to print something after a number of turns (guessing game) QTPi 4 2,807 Jun-18-2020, 04:59 PM
Last Post: QTPi
  A beginner code... TheDude 7 3,327 Jun-18-2020, 05:39 AM
Last Post: TheDude
  [Beginner] Code is not producing desired result fakej171 2 2,462 Mar-21-2020, 10:26 AM
Last Post: buran
  what function should i use to tidy up my code (extreme beginner) scraig0117 4 2,324 Dec-16-2019, 04:03 PM
Last Post: scraig0117
  Beginner at Python. Trying to count certain integer from random string of code kiaspelleditwrong 3 2,449 Oct-14-2019, 10:40 AM
Last Post: perfringo
  Beginner trying to code in python RA0211 1 1,861 Sep-26-2019, 11:10 AM
Last Post: emryscass
  [Help] Beginner's code Owenix 3 2,772 Sep-15-2018, 08:03 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