def money (mula,dime):
return mula+dime
final = money(3,5)
print final
if final == 8:
print "whyyy" .center(54)
if final == 8:
print "true" .center(54)
print final * 3 .center(65)
how can i get my final answer(print final *3 .center(65)) to be in the center. Everytime i try to run it, it just dosent work.
Traceback (most recent call last):
File "C:\Users\Patrick\path\to\test.py", line 6, in <module>
new_str = my_str.replace('c', 77)
TypeError: replace() argument 2 must be str, not int
Ah! …It seems that I need the int 77 to become a string, ‘77’
final = money(3,5)
print final
if final == 8:
print “whyyy” .center(54)
if final == 8:
print “true” .center(54)
print final * 3
so how would i get the print final* 3 to be in the middle right away when it prints. because when i click run it showes the answer(24) all the way to the left side. how can i get it to print in the middle.
I don’t know exactly what you are trying to do. Would you post a link to the problem so that we are all talking about the same thing?
Along with that, please post an example of how you would like the output to look. Use the </> icon in the menu bar at the top of the text box, and type your desired output where you see “Preformatted text” highlighted.
When you post your code, also make use of the same </> icon. Go to a free line, click the icon, and paste your code in where it says “type or paste code here”
If you do these things, it will be much easier to help you.
As factoradic explained above, final * 3 will result in an integer, so you need cast it to a string first before you can use the string method .center() on it.
You can do that by changing your last line as follows: