Python Forum
Multi set string inputs/outputs
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multi set string inputs/outputs
#2
Do you want to print all the information for each of the inputs, or just some of them?

You could have a list of random information and print one or two. Or you could characterize them like "season_info" and "average_temp" and pick what information is returned or printed.

I'd probably prefer to store everything in a separate file with some structure and read it in. For now, maybe lets just put it in JSON format.

month.json
{"January":[
   "Northern Hemisphere Winter",
   "Average high temp is 46F",
   "Named for the Roman god Janus"
   ]
}
code
import json

INFOFILE = "month.json"

f = open(INFOFILE, "r")
monthdata = json.load(f)

query = input("What's your input? ")
if monthdata.get(query):
    for info in monthdata[query]:
        print(info)
else:
    print(f"I have no information on {query}")
Output:
What's your input? January Northern Hemisphere Winter Average high temp is 46F Named for the Roman god Janus
Output:
What's your input? February I have no information on February
Reply


Messages In This Thread
Multi set string inputs/outputs - by kwmcgreal - Sep-26-2020, 06:19 PM
RE: Multi set string inputs/outputs - by bowlofred - Sep-26-2020, 09:39 PM
RE: Multi set string inputs/outputs - by kwmcgreal - Sep-26-2020, 10:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  format json outputs ! evilcode1 3 1,691 Oct-29-2023, 01:30 PM
Last Post: omemoe277
  Formatting outputs created with .join command klairel 2 592 Aug-23-2023, 08:52 AM
Last Post: perfringo
  I have written a program that outputs data based on GPS signal kalle 1 1,132 Jul-22-2022, 12:10 AM
Last Post: mcmxl22
  Why does absence of print command outputs quotes in function? Mark17 2 1,341 Jan-04-2022, 07:08 PM
Last Post: ndc85430
  Thoughts on interfacing with a QR code reader that outputs keystrokes? wrybread 1 1,447 Oct-08-2021, 03:44 PM
Last Post: bowlofred
  Combining outputs into a dataframe rybina 0 1,649 Mar-15-2021, 02:43 PM
Last Post: rybina
  ONE input => THREE outputs Tricia279 6 2,559 Jan-14-2021, 08:52 AM
Last Post: perfringo
  How to use subprocess to get multiple data outputs in desired folder? 3SG14 1 2,165 Sep-19-2020, 05:46 PM
Last Post: bowlofred
  How to write a response if a user inputs a string horuscope42 3 2,185 Apr-29-2020, 03:39 PM
Last Post: deanhystad
  Outputs missing SamAnw 4 2,537 Feb-12-2020, 04:32 PM
Last Post: adetheheat

Forum Jump:

User Panel Messages

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