I need a line of code that executes print(personal_data) after input(personal_data). Can someone help me?

Hello,

I'm currently learning Python and I'm stuck:

I have already tried :

 if input(personal_data) then print(personal data)

But it doesn't work because "then" isn't recognized. Please help me!

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
7 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
jo135
7 months ago

it does not work because “then” is not recognized. Please help me!

Sure. There is no keyword “then” in Python. That’s right:

https://docs.python.org/3/tutorial/controlflow.html#if-statements

if input(personal_data)

What do you expect? Here it would be checked whether input returns something other than an empty string (or none). I can make sense, but I don’t know if you want to. Since the result is not used, the input is at any rate lost – input() takes as parameter a prompt (i.e. a text that is displayed before the input). It cannot change the content of the variable.

The double point after that, of course, is missing.

the whole code is:

And that’s completely different code. You should describe what your goal is.

gogogo
7 months ago

Your syntax is wrong

At Python you have to press in and at the if I think instead of then put a double point.

I’ll give you another Python code with ‘if’.

Use Python extremely rare, therefore my uncertainty

gogogo
7 months ago
Reply to  Leland2010

Again:

At Python MUSST you move in. Here the print-statement

Xandros0506
7 months ago

I’ve tried

should be clear that this does not work, because the Input function as a criterion for a condition does not show much.

By the way:

personal_data is a Tuple. Then why do you know the associated values without brackets?

tuple = ( a, b, c, ...)
jo135
7 months ago
Reply to  Xandros0506

because the Input function as a criterion for a condition does not show much

may not be. input() returns strings. An empty string would be “falsy”, i.e. the condition would not be fulfilled.

personal_data is a Tuple. Then why do you know the associated values without brackets?

A tuple becomes not determined by clamps, but by communication-separated values. This, for example, is a tuple with an element:

t = 1,