Giter Club home page Giter Club logo

picnic_game's Introduction

Picnic Game

It is not just a game... so what is the purpose of this tiny python project, you might be asking.

With this picnic_game project, I have been able to:

  • write a program that accepts multiple positional arguments
  • use if, elif, and else to handle conditional branching with three or more options
  • find and alter items in a list
  • format a list into a new string

The program that will correctly format the items we're taking on our picnic. For one item, it should print the one item:

$ ./picnic.py sandwiches
You are bringing sandwiches.

For two items, place "and" in between:

$ ./picnic.py sandwiches chips
You are bringing sandwiches and chips.

For three or more items, use commas and "and":

$ ./picnic.py sandwiches chips cake
You are bringing sandwiches, chips, and cake.

If the --sorted flag is present, the items should first be sorted:

$ ./picnic.py sandwiches chips cake --sorted
You are bringing cake, chips, and sandwiches.

If no items are given, print a brief usage:

$ ./picnic.py
usage: picnic.py [-h] [-s] str [str ...]
picnic.py: error: the following arguments are required: str

if the --comma flag is present, then the the Oxford comma is removed:

$ ./picnic.py sandwiches chips cake
You are bringing sandwiches, chips and cake.

if the --char flag is present, the items are seperated by the given character:

$ ./picnic.py sandwiches chips cake
You are bringing sandwiches: chips: cake

Respond to -h and --help with a longer usage:

$ ./picnic.py -h
usage: picnic.py [-h] [-s] str [str ...]

Picnic game

picnic_game's People

Contributors

preshcode007 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.