Python Forum
Find Longest streak for habits
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find Longest streak for habits
#3
(Sep-11-2022, 10:10 PM)deanhystad Wrote: What is your thinking here? What is this function supposed to do?
def longest_streak(db, name):
    cur = db.cursor()
    cur.execute('SELECT streak FROM count WHERE name=?', (name,))
    long = cur.fetchall()
    for row in long:
        print("Here is your longest streak ")
        print(row[0])

This function suppose to find the longest streak of given habit.
the user enter the name of the habit name of the habit than

command line interface

if long == "Longest Streak Of Specific Habit":
lon_streak = questionary.text("Enter the name of habit for which you want to see the longest streak").ask()
get_longest_streak(db, lon_streak)

analytic.py file

def get_longest_streak(db, name):
"""

:param db: an initiated habit data
:param streak:number of days of continuity
:return:number of days in integer
"""
list = longest_streak(db, name)
return list

Attached Files

Thumbnail(s)
   
Reply


Messages In This Thread
Find Longest streak for habits - by johnconar - Sep-10-2022, 05:30 PM
RE: Find Longest streak for habits - by deanhystad - Sep-11-2022, 10:10 PM
RE: Find Longest streak for habits - by johnconar - Sep-12-2022, 08:52 AM
RE: Find Longest streak for habits - by deanhystad - Sep-12-2022, 07:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Print the longest str from user input edwdas 5 4,285 Nov-04-2019, 02:02 PM
Last Post: perfringo
  Print The Length Of The Longest Run in a User Input List Ashman111 3 3,274 Oct-26-2018, 06:56 PM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

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