+ 1
How would this be done?
Write a line of code that *converts x to be an int and *stores it back into x
11 RĂ©ponses
+ 1
Sorry, I meant X was a sting in my reply.
+ 1
Wouldnât you think your answer here is probably what heâs looking for? I know itâs simple question. Iâm just still learning.
x = 15.4 (or whatever)
print(int(x))
+ 1
He didnât give us one, which was why I was confused I guess. The problem he gave us is exactly what I started this thread with.
Write a line of code that
*converts x to be an int and
*stores it back into x
0
First off, thanks for answering so quickly.
This is my professors question and he wants us to type the code for it.
Iâm not understanding the question because we werenât given an integer unless I can just make one up. And how would I convert x if itâs just a string?
0
if your x is string and want to store it as int just
x = int(x)
you cant pass non numeral strings like "abcd" into int function.