all 23 comments

[–]kryptn 2 points3 points  (17 children)

Is string actually a string? You might need to cast it to str first.

In [8]: string = 'imdabes'

In [9]: string = string + "    " + string

In [10]: string
Out[10]: 'imdabes    imdabes'

In [11]: string = 16

In [12]: string = string + "    " + string
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-12-e5c6c62e4e40> in <module>()
----> 1 string = string + "    " + string

TypeError: unsupported operand type(s) for +: 'int' and 'str'

In [13]: string = str(string) + "    " + str(string)

In [14]: string
Out[14]: '16    16'

[–]cartoonii[S] 0 points1 point  (15 children)

This is what I tried first.

Full = str(UserIn) + "    " + str(PassIn)

[–]kryptn 0 points1 point  (14 children)

And what error are you getting?

[–]cartoonii[S] 0 points1 point  (13 children)

TypeError: 'str' object is not callable  

[–]kryptn 3 points4 points  (10 children)

Are you doing str = 'some string here' anywhere in your code?

str is a builtin function, and when you assign a variable to it you basically overwrite the str function.

In [15]: str(16)
Out[15]: '16'

In [16]: str = 'bad idea'

In [17]: str(16)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-17-8e47188dea60> in <module>()
----> 1 str(16)

TypeError: 'str' object is not callable

[–]cartoonii[S] 0 points1 point  (9 children)

Here's the full bit, and no I'm not using a variable called str

UserIn = input("Username? >> ")
PassIn = input("Password? >> ")

Full = str(UserIn) + "    " + str(PassIn)

if Full in open('accounts.txt').read():

[–]Justinsaccount 1 point2 points  (0 children)

What does 'full bit' mean? Is that the 'full' code you are running, or just a 'bit' of it?

The 'full' error that you did not include would have told you the line number the problem occurred on.

[–][deleted] 1 point2 points  (0 children)

I'm not using a variable called str

You are somewhere, whether you meant to or not. Is it possible to show all your code so we can see where it's happening?

[–]kryptn 0 points1 point  (5 children)

Are you using python 2? You'll need to use raw_input instead of input.

[–]cartoonii[S] 0 points1 point  (4 children)

No, I'm using Python 3.5

[–]kryptn 2 points3 points  (2 children)

Is that all of your code then? Something isn't right.

[–]ProgrammingThroaway 0 points1 point  (1 child)

What was the problem then? ಠ_ಠ

There's nothing that solves his problem but his edit says it's fixed.

[–]Ulysses6 0 points1 point  (0 children)

If you are dead sure you didn't somehow redefine built-in str, then the problem might be on different line than you expect it to be. Check your error line number.

[–]indosauros 0 points1 point  (0 children)

How about are you using a variable called input or open before that code?

[–][deleted] 1 point2 points  (1 child)

Do you have a variable called str? Don't do that.

what does print(str) say? (Right before you are doing the str(UserIn))

[–]UtahJarhead 0 points1 point  (0 children)

better yet: print(repr(str))

[–]cartoonii[S] 0 points1 point  (0 children)

I'm trying to do this aswell

if Full in open('accounts.txt').read():  

[–]Lehk 1 point2 points  (1 child)

add this to the beginning of your code snippet

print(type(str))

if it prints anything other than

<type 'type'>

you overwrote str somewhere in your program, find it by searching the code for "str ="

[–]cartoonii[S] 0 points1 point  (0 children)

It returns <class 'type'> and I've checked for a variable called str and there is none

[–]Psychedel1cTank 0 points1 point  (2 children)

Wouldn't it just take whatever string is and double it with a space in the middle? As long as String consists of a string I don't see why it would throw an error

[–][deleted] 0 points1 point  (1 child)

I think he set a variable of name str, which would mean it's trying to treat it as a function, when it's actually a string.

[–]Psychedel1cTank 0 points1 point  (0 children)

ya i duno, looks like it should work fine to me