Question

I am trying to print an essay in my python code but the words keep getting...

I am trying to print an essay in my python code but the words keep getting cut over two lines. How can i fix this using python code so that it is formatted nicely? thanks

Homework Answers

Answer #1

Python wonders that how to print two or more Statements or variables without going into a new line in python. Since the python print() function by default ends with newline. Python has a predefined format if you use print(a_variable) then it will go to next line automatically.

To print multiple expressions to the same line, you can end the print statement in Python 2 with a comma ( , ). In Python 3, you can set the end parameter to a whitespace character string. With Python 3, you do have the added flexibility of changing the end paramter to anything you want.

The new line character in Python is indicated as \n . It is used to show the end of a line of text. You can print strings without adding a new line with end = <character> , which <character> is the character that will be used to separate the lines.

The answer discussed is totally dependent on the python version you are using.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using Python (pandas as pd) I am trying to use the split, apply, combine method but...
Using Python (pandas as pd) I am trying to use the split, apply, combine method but am getting an "invalid syntax" error at the end of the line that says "for days_name, days_df in grouped_by_day" I declared grouped_by_day in the split function but did not get any errors so I am not sure what happened or how to fix it. Below is a copy of the split, apply, combine section of my code. mean_data_ser = pd.Series() #split grouped_by_day= days_df.groupby("Day of...
How can I change my username so that the getuser Python output is different? I am...
How can I change my username so that the getuser Python output is different? I am using a windows pc import datetime import getpass print("\n\nFinished execution at ", datetime.datetime.now()) print(getpass.getuser())
I am working on exercise 5.30 from Introduction to Computing using python (Author: Perkovic). I was...
I am working on exercise 5.30 from Introduction to Computing using python (Author: Perkovic). I was looking at the solution and was able to understand what to do. However, when I implement the temp function as indicated, I keep getting this error "ValueError: the first two maketrans arguments must have equal length". However, it seems my two arguments are equal length, so I'm not sure what I am doing wrong! print('Exercise 5.30') def many(file): infile = open(file) content = infile.read()...
why am I getting this error with this code? :print('Women: {:.2f} calories'.format('calories_woman')) THIS IS THE ERROR...
why am I getting this error with this code? :print('Women: {:.2f} calories'.format('calories_woman')) THIS IS THE ERROR I AM GETTING :ValueError: Unknown format code 'f' for object of type 'str'
Hello, I am trying to write a program in python that will determine if a sentence...
Hello, I am trying to write a program in python that will determine if a sentence has every letter in the alphabet, regardless if it is upper or lower case. The program needs to indicate if all letters are present or not, and print out the missing letters if there are any. Thanks for any help in advance.
In Python (using pandas and numpy) I am trying to clean CSV data so it adheres...
In Python (using pandas and numpy) I am trying to clean CSV data so it adheres to a strict coding system instead of free response. More specifically, how would I code a simple rule based system to handle the various spellings and word choices that represent the following statuses: Never married Divorced Married Widowed Separated
How do I code these in Python? My final result should be "Monday 4" day =...
How do I code these in Python? My final result should be "Monday 4" day = Monday square = 2 ^ 2 print (square) print(day + square)
In python: I am trying to construct a list using enumerate and takewhile from a Fibonaci...
In python: I am trying to construct a list using enumerate and takewhile from a Fibonaci generator. So far the code I have is the following: def fibonacci(): (a, b) = (0, 1) while True: yield a (a, b) = (b, a + b) def createlist(n, fib): return [elem for (i, elem) in enumerate(takewhile(lambda x: x < n, fib)) if i < n] I only get half the list when I do: print(createlist(n, fibonacci())) Output: [0, 1, 1, 2, 3,...
I am very new to coding and I am trying to understand how I can go...
I am very new to coding and I am trying to understand how I can go about connecting my Java Program to my Java GUI? I built my JAVA program using eclipse, I created a database using mysql workbench and connected the two (java program and mysql database). I also created two GUI interfaces using Netbeans but Im not sure how to bring these together?
I am trying to print out an 8 by 8 "chess board". My first step is...
I am trying to print out an 8 by 8 "chess board". My first step is to set all values in the board to 0. I made a function to do so but it isn't working, and i can't figure out why. I'm trying to, for now, simply print out an 8 by 8 of zero values. This is what I have: (C++) // set all of board to 0 as a function // bool function to check for valid...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT