Maijaz09


#1

name = raw_input("What is your name?")
quest = raw_input("What is your quest?")
color = raw_input("What is your favorite color?")

print "Ah, so your name is %s , your quest is %s , " \
"and your favorite color is %s." % (name, quest, color)

can any one tell me how to write this code in python 3.6


#2

In python 3.x, raw_input() is now input()
and print now has parenthesis because it is a function.

in python 3 should be

name = input("What is your name?")

I hope this works for you!

Edit: Roy covered how to format strings because I had it wrong.


#3

In Python 3 we have the new format() function:

print ("Ah, so your name is {}, your quest is {}, and your favorite \
 color is {}.".format(name, quest, color))

@stetim94 posted this link the other day that you will find useful.

https://pyformat.info/


#4

Ah, i wondered if there was a new way to format, thanks.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.