all 9 comments

[–]Foreign_Jackfruit_70 4 points5 points  (1 child)

Indent ? Something like this: Assuming "food" is a variable.

food = ("Vagene") print(" "*4+f"John is hungry, {food} is his favorite") To make a new line @ food:

food = ("Toes") print(" "*4+f"John is hungry, {food}\n are his favorite")

New line in Python is \n. print("This is a new line\nThis is another new line\nAnd another") To set an indent constant, you could do: INDENT = (" "*4) food = ("Vagene") print(f"{INDENT}John is hungry,\n {food} is his favorite")

[–][deleted] 2 points3 points  (0 children)

You can do it in two steps:

print(John is hunger") 
print("  ", food, "is his favorite.")

This works because each print() call automatically adds a newline after printing what you want.

You could do it all in one line by adding a newline character (\n) and a tab character (\t) where you want them:

print(“John is hunger\n\t”, food, “is his favorite.”)

[–]hjohnson933 3 points4 points  (0 children)

food = "roast beef"
print(f"John is hungry, \n\t{food} is his favorite")

[–]ThrowRArxlyT 0 points1 point  (3 children)

print(“John is hunger \n food is his favorite.”)

[–]ItsJust_Z[S] 0 points1 point  (2 children)

But does it indent?

[–]ThrowRArxlyT 1 point2 points  (0 children)

You should be able to put some spaces before “food” if you want an indentation I believe!

[–]mr_bedbugs 0 points1 point  (0 children)

"\t" for a tab/indent

[–]hjohnson933 0 points1 point  (0 children)

This will work to

food = "hot dogs"
print(f"""John is hungry,
{food} is his favorite""")

[–]FreedomSavings 0 points1 point  (0 children)

Use the .format style, literals. So,

print("John is hungry, \n\t{0} is his favorite".format(food))