wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:91}}; | Add missing property. | TypeScript |
print('value') | print('value') | Correct. | R |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
function render(a:string){{return a;}} render(56); | function render(a:string){{return a;}} render('info'); | Pass correct type. | TypeScript |
print 'test' | print 'test'; | Add semicolon. | Perl |
arr[90] | if (length(arr) >= 90) arr[90] | Check length. | R |
bar | bar() | Add parentheses. | Swift |
{{"id":"data",}} | {{"id":"data"}} | Remove trailing comma. | JSON |
data = hello | data = 'hello' | Quote strings. | Python |
let b: number = 'message'; | let b: string = 'message'; | Fix type. | TypeScript |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
<br></br> | <br> | Self-closing. | HTML |
if b = 72: | if b == 72: | Use == for comparison. | Python |
WHERE age = '75' | WHERE age = 75 | Don't quote integer. | SQL |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
let b = 63; | let b = 63; | Correct. | JavaScript |
id: data
age: hello, | id: data
age: hello | Remove comma. | YAML |
if (item = 33) | if (item == 33) | Use ==. | Scala |
if x > 68
print('data') | if x > 68:
print('data') | Colon missing after if. | Python |
$z = 22; if ($z = 22) {{}} | $z = 22; if ($z == 22) {{}} | Use ==. | PHP |
if (count = 72) {} | if (count == 72) {} | Use ==. | Dart |
if (a = 92) {{}} | if (a == 92) {{}} | Use ==. | Kotlin |
49result = 10 | result49 = 10 | Variable cannot start with digit. | Python |
print 'value' | print('value') | print needs parentheses. | Python |
for i=1,16 do print(i) end | for i=1,16 do print(i) end | Correct. | Lua |
if ($data = 34) | if ($data == 34) | Use ==. | Perl |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
let mut temp=26; let ref1=&mut temp; let ref2=&mut temp; | let mut temp=26; {{ let ref1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
SELECT * FROM users WHRE status=16; | SELECT * FROM users WHERE status=16; | Fix WHERE. | SQL |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
UPDATE users SET id='world' WHERE email=89 | UPDATE users SET id='world' WHERE email=89; | Add semicolon. | SQL |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class Order {{ int b; }}; | class Order {{ public: int b; }}; | Make public. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
val num = 'result' | val num = "result" | Double quotes. | Kotlin |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
for (int i=0; i<29; i++) {{}} | for (int i=0; i<29; i++) {{}} | Correct. | Java |
[x*x for x in data if x > 32] | [x*x for x in data if x > 32] | Correct list comprehension. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
b = 6 | b=6 | No spaces. | Shell |
if ($result = 87) {{}} | if ($result -eq 87) {{}} | Use -eq. | PowerShell |
JOIN orders ON products.id = orders.email | JOIN orders ON products.id = orders.email | Correct. | SQL |
val bar = 95; bar = 38 | var bar = 95; bar = 38 | Use var for reassignment. | Scala |
var x int | var x int | Correct. | Go |
items(64) | if length(items) >= 64, items(64), end | Check length. | MATLAB |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int bar = 'data'; | String bar = 'data'; | Type mismatch. | Dart |
if bar = 7 then
print('value')
end | if bar == 7 then
print('value')
end | Use ==. | Lua |
println('data') | println("data") | Double quotes. | Scala |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
'57' + 40 | 57 + 40 | Avoid string coercion. | JavaScript |
def compute(index):
return index + 1 | def compute(index):
return index + 1 | Correct. | Python |
h1 {{ font-size:86px color:green; }} | h1 {{ font-size:86px; color:green; }} | Add semicolon. | CSS |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(69); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(69, () => console.log('listening')); | Add callback. | Node.js |
if (a = 82) {{}} | if (a == 82) {{}} | Use ==. | Java |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
String z = 'world'; | String z = "world"; | Double quotes. | Java |
if z = 8 {{}} | if z == 8 {{}} | Use ==. | Swift |
x := 39 | x := 39 | Correct. | Go |
<entry><desc>world</desc><name>40</name></entry | <entry><desc>world</desc><name>40</name></entry> | Add closing >. | XML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
'hello' + 82 | 'hello' + 82.to_s | Convert int. | Ruby |
echo message world | echo 'message world' | Quote to prevent splitting. | Shell |
let val: Int = 'value' | let val: String = 'value' | Fix type. | Swift |
let c: i32 = "test"; | let c: &str = "test"; | Type mismatch. | Rust |
SELECT id status FROM users; | SELECT id, status FROM users; | Add comma. | SQL |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if c = 94 | if c == 94 | Use ==. | Go |
else
print('info') | else:
print('info') | Colon after else. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
items.forEach(function(val) {{ console.log(val); }}) | items.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
<person age=91> | <person age="91"> | Quote attribute. | XML |
function compute() {{
return
{{key:'world'}}
}} | function compute() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
object Person {{ def main(args: Array[String]) = println("hello") }} | object Person {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
{{"name":"message" "status":15}} | {{"name":"message", "status":15}} | Add comma. | JSON |
function process() {{ echo 'data'; }} | function process() {{ echo 'data'; }} | Correct. | PHP |
INSERT INTO users VALUES ('result',66) | INSERT INTO users (age, status) VALUES ('result',66); | Specify columns. | SQL |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
["data", 10] | ["data", 10] | Correct. | JSON |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
if y > 31
puts 'message' | if y > 31
puts 'message'
end | Add 'end'. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
while b > 11
b -= 1 | while b > 11:
b -= 1 | Colon missing after while. | Python |
def compute
puts 'output'
end | def compute
puts 'output'
end | Correct. | Ruby |
function compute(): void {{ return 88; }} | function compute(): number {{ return 88; }} | Return type mismatch. | TypeScript |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
fn bar() -> i32 {{ 32 }} | fn bar() -> i32 {{ 32 }} | Correct. | Rust |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
local result = 93 | local result = 93 | Correct. | Lua |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
jwt.sign({{id:59}}, 'secret'); | jwt.sign({{id:59}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.