Problems with Python code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Helmuts Helmuts
    New Member
    • Nov 2020
    • 1

    Problems with Python code

    Hello, guys! I probably shouldn't mentioned it, because in other forums no one really wanted to help me after I mentioned that I need this for my programming test at school, but I'm really desperate. I will attach my code and errors in it, I don't really understand what is wrong with these errors and how can I fix them. I am already trying to write that program for 3 days. But if I can't get pass this test, it looks like there is almost 100 percent chance for me not to make to next grade. And also don't misunderstood me- I don't want to get into job as a programmer, but I have that subject at school. And if someone really helps me, please explain as simple as you can, because I really don't understand what these errors mean. Really hope on your help, because I'm myself hopeless with this. Thank you :)))




    x = int(input())
    a = 12
    sestdiena = x//a
    sestdienaa = x%a
    print(sestdiena , str(sestdienaa) + "/" + str(a))
    print("Sestdien piepildīja" + sestdiena + "kastītes, nepilnajā kastītē bija" + sestdienaa + " olas .")

    Traceback (most recent call last):
    File "jdoodle.py ", line 6, in <module>
    print("Sestdien piepildīja" + sestdiena + "kastītes, nepilnajā kastītē bija" + sestdienaa + " olas .")
    TypeError: can only concatenate str (not "int") to str



    x = int(input())
    y = int(input())
    a = 12
    sestdiena = x//a
    sestdienaa = x%a
    print(sestdiena , str(sestdienaa) + "/" + str(a))
    print("Sestdien piepildīja" + sestdiena + "kastītes, nepilnajā kastītē bija" + sestdienaa + " olas .")




    File "jdoodle.py ", line 2, in <module>
    y = int(input())
    ValueError: invalid literal for int() with base 10: ''
  • Sariel
    New Member
    • Nov 2020
    • 1

    #2
    EDIT: Deleted my answer due to rules about course work.

    Comment

    • dev7060
      Recognized Expert Contributor
      • Mar 2017
      • 656

      #3
      TypeError: can only concatenate str (not "int") to str
      Use str() to concatenate a string with an int.
      Code:
      print("Sestdien piepildīja " + str(sestdiena) + " kastītes, nepilnajā kastītē bija " + str(sestdienaa) + " olas .")
      ValueError: invalid literal for int() with base 10: ''
      The provided argument can't be parsed as int. Look out for the provided inputs.

      Comment

      Working...