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 661 Yesterday, 07:07 AM
Last Post: Bronjer
  Waiting for input from serial port, then move on KenHorse 3 1,000 Apr-17-2024, 07:21 AM
Last Post: DeaD_EyE
  Help with to check an Input list data with a data read from an external source sacharyya 3 402 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  difference between forms of input a list to function akbarza 6 1,020 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  pyaudio seems to randomly halt input. elpidiovaldez5 2 362 Jan-22-2024, 09:07 AM
Last Post: elpidiovaldez5
  run SQL without user intervention python dawid294 0 230 Jan-19-2024, 01:11 PM
Last Post: dawid294
  Receive Input on Same Line? johnywhy 8 703 Jan-16-2024, 03:45 AM
Last Post: johnywhy
  manually input data jpatierno 0 340 Nov-10-2023, 02:32 AM
Last Post: jpatierno
  Using string input for boolean tronic72 3 687 Nov-01-2023, 07:48 AM
Last Post: Gribouillis
  problem in using input command akbarza 4 1,102 Oct-19-2023, 03:27 PM
Last Post: popejose

Forum Jump:

User Panel Messages

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