By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,553 Members | 869 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,553 IT Pros & Developers. It's quick & easy.

Problems with Python code

P: 1
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: ''
2 Weeks Ago #1
Share this Question
Share on Google+
2 Replies

P: 1
EDIT: Deleted my answer due to rules about course work.
2 Weeks Ago #2

dev7060
Expert 100+
P: 336
TypeError: can only concatenate str (not "int") to str
Use str() to concatenate a string with an int.
Expand|Select|Wrap|Line Numbers
  1. 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.
2 Weeks Ago #3

Post your reply

Sign in to post your reply or Sign up for a free account.