Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
deleted 48 characters in body
Source Link
Ejay
  • 1
  • 1

I am having trouble figuring out this pset. Every time, I use check50 it shows many red faces.

from datetime import date
import sys
import re
# pip imported library to convert numbers into word format
from num2words import num2words


def main():
    print(convert(input("Date of Birth: ")))


def convert(dob):
    # Validates user input
    if re.search(r'^([1-2][0-9][0-9][0-9])-([0-1][0-9])-([0-3][0-9])$', dob):
        today = date.today()
        try:
            # Validate date format
            input_date = date.fromisoformat(dob)
        except ValueError:
            sys.exit("Invalid Date")
    # Calulations
    minus = today - input_date
    calculation = minus.days * 24 * 60
    word_form = num2words(calculation)

    # removes the word 'and'
    final = re.sub(r' and', '', word_form)

    return f'{final.capitalize()} minutes'

else:
    sys.exit("Invalid Date")


if __name__ == "__main__":
    main()

enter image description here

Thank you for the suggested and all is working well. TheEdit: The indentation wereis my mistake while writing this form. My main problem is when using check50 and nothing is being outputted but, when I run the program locally it outputs the correct sentence.

I am having trouble figuring out this pset. Every time, I use check50 it shows many red faces.

from datetime import date
import sys
import re
# pip imported library to convert numbers into word format
from num2words import num2words


def main():
    print(convert(input("Date of Birth: ")))


def convert(dob):
    # Validates user input
    if re.search(r'^([1-2][0-9][0-9][0-9])-([0-1][0-9])-([0-3][0-9])$', dob):
        today = date.today()
        try:
            # Validate date format
            input_date = date.fromisoformat(dob)
        except ValueError:
            sys.exit("Invalid Date")
    # Calulations
    minus = today - input_date
    calculation = minus.days * 24 * 60
    word_form = num2words(calculation)

    # removes the word 'and'
    final = re.sub(r' and', '', word_form)

    return f'{final.capitalize()} minutes'

else:
    sys.exit("Invalid Date")


if __name__ == "__main__":
    main()

enter image description here

Thank you for the suggested and all is working well. The indentation were my mistake while writing this form. My main problem is when using check50 and nothing is being outputted but, when I run the program locally it outputs the correct sentence.

I am having trouble figuring out this pset. Every time, I use check50 it shows many red faces.

from datetime import date
import sys
import re
# pip imported library to convert numbers into word format
from num2words import num2words


def main():
    print(convert(input("Date of Birth: ")))


def convert(dob):
    # Validates user input
    if re.search(r'^([1-2][0-9][0-9][0-9])-([0-1][0-9])-([0-3][0-9])$', dob):
        today = date.today()
        try:
            # Validate date format
            input_date = date.fromisoformat(dob)
        except ValueError:
            sys.exit("Invalid Date")
    # Calulations
    minus = today - input_date
    calculation = minus.days * 24 * 60
    word_form = num2words(calculation)

    # removes the word 'and'
    final = re.sub(r' and', '', word_form)

    return f'{final.capitalize()} minutes'

else:
    sys.exit("Invalid Date")


if __name__ == "__main__":
    main()

enter image description here

Edit: The indentation is my mistake while writing this form. My main problem is when using check50 and nothing is being outputted but, when I run the program locally it outputs the correct sentence.

added 257 characters in body
Source Link
Ejay
  • 1
  • 1

I am having trouble figuring out this pset. Every time, I use check50 it shows many red faces.

from datetime import date
import sys
import re
# pip imported library to convert numbers into word format
from num2words import num2words


def main():
    print(convert(input("Date of Birth: ")))


def convert(dob):
    # Validates user input
    if re.search(r'^([1-2][0-9][0-9][0-9])-([0-1][0-9])-([0-3][0-9])$', dob):
        today = date.today()
        try:
            # Validate date format
            input_date = date.fromisoformat(dob)
        except ValueError:
            sys.exit("Invalid Date")
    # Calulations
    minus = today - input_date
    calculation = minus.days * 24 * 60
    word_form = num2words(calculation)

    # removes the word 'and'
    final = re.sub(r' and', '', word_form)

    return f'{final.capitalize()} minutes' 

else:
    sys.exit("Invalid Date")


if __name__ == "__main__":
    main()

enter image description here

Thank you for the suggested and all is working well. The indentation were my mistake while writing this form. My main problem is when using check50 and nothing is being outputted but, when I run the program locally it outputs the correct sentence.

I am having trouble figuring out this pset. Every time, I use check50 it shows many red faces.

from datetime import date
import sys
import re
# pip imported library to convert numbers into word format
from num2words import num2words


def main():
    print(convert(input("Date of Birth: ")))


def convert(dob):
    # Validates user input
    if re.search(r'^([1-2][0-9][0-9][0-9])-([0-1][0-9])-([0-3][0-9])$', dob):
        today = date.today()
        try:
            # Validate date format
            input_date = date.fromisoformat(dob)
        except ValueError:
            sys.exit("Invalid Date")
    # Calulations
    minus = today - input_date
    calculation = minus.days * 24 * 60
    word_form = num2words(calculation)

    # removes the word 'and'
    final = re.sub(r' and', '', word_form)

    return f'{final.capitalize()} minutes'
else:
    sys.exit("Invalid Date")


if __name__ == "__main__":
    main()

enter image description here

I am having trouble figuring out this pset. Every time, I use check50 it shows many red faces.

from datetime import date
import sys
import re
# pip imported library to convert numbers into word format
from num2words import num2words


def main():
    print(convert(input("Date of Birth: ")))


def convert(dob):
    # Validates user input
    if re.search(r'^([1-2][0-9][0-9][0-9])-([0-1][0-9])-([0-3][0-9])$', dob):
        today = date.today()
        try:
            # Validate date format
            input_date = date.fromisoformat(dob)
        except ValueError:
            sys.exit("Invalid Date")
    # Calulations
    minus = today - input_date
    calculation = minus.days * 24 * 60
    word_form = num2words(calculation)

    # removes the word 'and'
    final = re.sub(r' and', '', word_form)

    return f'{final.capitalize()} minutes' 

else:
    sys.exit("Invalid Date")


if __name__ == "__main__":
    main()

enter image description here

Thank you for the suggested and all is working well. The indentation were my mistake while writing this form. My main problem is when using check50 and nothing is being outputted but, when I run the program locally it outputs the correct sentence.

Source Link
Ejay
  • 1
  • 1

CS50P - Seasons of Love

I am having trouble figuring out this pset. Every time, I use check50 it shows many red faces.

from datetime import date
import sys
import re
# pip imported library to convert numbers into word format
from num2words import num2words


def main():
    print(convert(input("Date of Birth: ")))


def convert(dob):
    # Validates user input
    if re.search(r'^([1-2][0-9][0-9][0-9])-([0-1][0-9])-([0-3][0-9])$', dob):
        today = date.today()
        try:
            # Validate date format
            input_date = date.fromisoformat(dob)
        except ValueError:
            sys.exit("Invalid Date")
    # Calulations
    minus = today - input_date
    calculation = minus.days * 24 * 60
    word_form = num2words(calculation)

    # removes the word 'and'
    final = re.sub(r' and', '', word_form)

    return f'{final.capitalize()} minutes'
else:
    sys.exit("Invalid Date")


if __name__ == "__main__":
    main()

enter image description here