Python Forum
How to format characters that are given by user input with user input
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to format characters that are given by user input with user input
#1
I am writing a program (in Python 3.7.2) that is supposed to print out a flag with the width of the flag being user input and the characters used in the flag also being user input. I am having difficulty in formatting the characters according to user input. This is what I have so far:
Greeting = “Hi, I’m flaggy the flagmaker. Let’s make a flag!”
print (Greeting)
width = (int (input (“What’s the width of your flag?”)))
if width > 0:
     print (width)
elif width < 1:
     print (input( “What’s the width of your flag?\n>”))
characters = input (“What characters would you like to use?\n>”)
if characters == :
     print (input (“What characters would you like to use\n>?”))
print (format (characters3))
str = [’>width’]
print [str. format [“characters”]]
print [str. format [“characters”]]
print (format (characters3))
*my issues are in the third to last and second to last lines where I know the format is incorrect but I’m not sure how to correct it.
Reply
#2
Check out the documentation format method of strings, and the full format method syntax here. Also, note that code with smart quotes won't run correctly. That means we can't run your code. That means it's harder for us to help you.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Randomly Print a Quote From a Text File When User Types a Command on Main Menu BillKochman 13 7,273 Dec-16-2025, 05:29 PM
Last Post: zodazy
Question Two arguments in input function Alfredd 4 811 Nov-09-2025, 12:56 AM
Last Post: Pedroski55
  extracting data from a user-completed fillable pdf Perry 2 1,579 Sep-25-2025, 01:49 PM
Last Post: DeaD_EyE
  Using a For Loop to subtract numbers from an input function. Anunderling 9 2,819 Sep-22-2025, 08:56 PM
Last Post: deanhystad
  data input while debugging causes unwanted code completion fred1232 2 2,688 Sep-14-2025, 03:32 PM
Last Post: deanhystad
Question Call CLI app with input? Winfried 5 1,293 May-23-2025, 07:52 PM
Last Post: snippsat
  Βad Input on line 12 Azdaghost 5 2,237 Apr-19-2025, 10:22 PM
Last Post: Azdaghost
  interactive process for input and output maiya 1 2,300 Mar-27-2025, 08:40 AM
Last Post: Gribouillis
  Warn user of validation error before they click submit robertkwild 1 1,359 Mar-12-2025, 03:49 AM
Last Post: Tishat73
  How to revert back to a previous line from user input Sharkenn64u 2 3,184 Dec-28-2024, 08:02 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020