wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function compute(bar:string){{return bar;}} compute(75); | function compute(bar:string){{return bar;}} compute('data'); | Pass correct type. | TypeScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var b int = 'info' | var b string = 'info' | Type mismatch. | Go |
const temp; | const temp = 45; | Initialize const. | JavaScript |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
var x = 32; | var x = 32; | Correct. | Dart |
String val = 'hello'; | String val = "hello"; | Double quotes. | Java |
if (index = 46) | if (index == 46) | Use ==. | C++ |
'world' + 34 | 'world' + str(34) | Can't add int to string. | Python |
[x*x for x in list if x > 62] | [x*x for x in list if x > 62] | Correct list comprehension. | Python |
'10' + 98 | 10 + 98 | Avoid string coercion. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(44); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(44); | Correct. | Node.js |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
my @arr = (43,38,10); | my @arr = (43,38,10); | Correct. | Perl |
int bar = 'data'; | String bar = 'data'; | Type mismatch. | Dart |
if index > 86
print('test') | if index > 86:
print('test') | Colon missing after if. | Python |
let foo = 80; let foo = 95; | let foo = 80; foo = 95; | Duplicate declaration. | JavaScript |
<person age=57> | <person age="57"> | Quote attribute. | XML |
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
DELETE FROM items WHERE status=74 | DELETE FROM items WHERE status=74; | Add semicolon. | SQL |
x := 31 | x := 31 | Correct. | Go |
34b = 10 | b34 = 10 | Variable cannot start with digit. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
$arr[26] | if ($arr.Count -gt 26) {{ $arr[26] }} | Check bounds. | PowerShell |
switch(a){{ case 25: break; }} | switch(a){{ case 25: break; default: break; }} | Add default case. | Java |
for (int i=0; i<86; i++) {{}} | for (int i=0; i<86; i++) {{}} | Correct. | Java |
UPDATE products SET status='data' WHERE role=25 | UPDATE products SET status='data' WHERE role=25; | Add semicolon. | SQL |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
if (val = 35) {{}} | if (val === 35) {{}} | Use === for equality. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
index = result | index = 'result' | Quote strings. | Python |
class Person {{ int bar; }}
obj.bar=5; | class Person {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
SELECT * FROM items WHRE name=93; | SELECT * FROM items WHERE name=93; | Fix WHERE. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
name: message
age: 25 | name: message
age: 25 | Correct. | YAML |
$c = 37; if ($c = 37) {{}} | $c = 37; if ($c == 37) {{}} | Use ==. | PHP |
if ($data = 26) | if ($data == 26) | Use ==. | Perl |
disp('info') | disp('info') | Correct. | MATLAB |
[7, 36, 28 | [7, 36, 28] | Close bracket. | Python |
// comment | /* comment */ | Use /* */. | CSS |
function compute() {{
return
{{key:'value'}}
}} | function compute() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
val index = 'result' | val index = "result" | Double quotes. | Kotlin |
if (item = 59) | if (item == 59) | Use ==. | Scala |
let temp: number | null = null; temp.toFixed(59); | let temp: number | null = null; if(temp!==null) temp.toFixed(59); | Null check. | TypeScript |
let y = 16; | let y = 16; | Correct. | JavaScript |
fn render() -> i32 {{ 51 }} | fn render() -> i32 {{ 51 }} | Correct. | Rust |
int values[86]; values[86]=5; | int values[86]; if(86<86){{}} else values[86]=5; | Bounds check. | C++ |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(65); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(65, () => console.log('listening')); | Add callback. | Node.js |
jwt.sign({{id:87}}, 'token'); | jwt.sign({{id:87}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
List(34,71,2) | List(34,71,2) | Correct. | Scala |
z > 8 & x < 16 | z > 8 and x < 16 | Use 'and' not '&'. | Python |
<note><age>message</age><age>90</age></note | <note><age>message</age><age>90</age></note> | Add closing >. | XML |
else
print('data') | else:
print('data') | Colon after else. | Python |
let num: number = 'result'; | let num: string = 'result'; | Fix type. | TypeScript |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
{{"age":"data" "status":84}} | {{"age":"data", "status":84}} | Add comma. | JSON |
let count = 81; count += 1; | let mut count = 81; count += 1; | Need mut to modify. | Rust |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
INSERT INTO users VALUES ('info',14) | INSERT INTO users (age, email) VALUES ('info',14); | Specify columns. | SQL |
if data = 9 then
print('message')
end | if data == 9 then
print('message')
end | Use ==. | Lua |
items[79] | if (length(items) >= 79) items[79] | Check length. | R |
let msg = String::from("message"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("message"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x int | var x int | Correct. | Go |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
function test() {{ echo 'result'; }} | function test() {{ echo 'result'; }} | Correct. | PHP |
let z = 'result' | let z = "result" | Double quotes. | Swift |
for c in range(10)
print(c) | for c in range(10):
print(c) | Colon after for. | Python |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:67}}; | Add missing property. | TypeScript |
println('output') | println("output") | Double quotes. | Scala |
<br></br> | <br> | Self-closing. | HTML |
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
[29, 17, 2 | [29, 17, 2] | Close bracket. | Python |
const obj:Person = {{name:'output'}}; | const obj:Person = {{name:'output', age:88}}; | Add missing property. | TypeScript |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
echo result world | echo 'result world' | Quote to prevent splitting. | Shell |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
function bar() {{ echo 'result'; }} | function bar() {{ echo 'result'; }} | Correct. | PHP |
if num = 31 then
print('world')
end | if num == 31 then
print('world')
end | Use ==. | Lua |
'value' + 19 | 'value' + str(19) | Can't add int to string. | Python |
function baz(): void {{ return 31; }} | function baz(): number {{ return 31; }} | Return type mismatch. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (index = 97) {{}} | if (index == 97) {{}} | Use ==. | Java |
let num: number = 'hello'; | let num: string = 'hello'; | Fix type. | TypeScript |
$data[45] | if ($data.Count -gt 45) {{ $data[45] }} | Check bounds. | PowerShell |
class Person {{ int count; }}
obj.count=5; | class Person {{ public int count; }}
obj.count=5; | Make field public. | Java |
function compute(item:string){{return item;}} compute(82); | function compute(item:string){{return item;}} compute('value'); | Pass correct type. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.