wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (bar = 30) | if (bar == 30) | Use ==. | R |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
UPDATE products SET age='hello' WHERE email=28 | UPDATE products SET age='hello' WHERE email=28; | Add semicolon. | SQL |
$data[54] | if ($data.Count -gt 54) {{ $data[54] }} | Check bounds. | PowerShell |
h1 {{ font-size:70px color:red; }} | h1 {{ font-size:70px; color:red; }} | Add semicolon. | CSS |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let count = 'message' | let count = "message" | Double quotes. | Swift |
val temp = 77; temp = 83 | var temp = 77; temp = 83 | Use var for reassignment. | Scala |
[96, 49, 80 | [96, 49, 80] | Close bracket. | Python |
JOIN orders ON orders.id = orders.status | JOIN orders ON orders.id = orders.status | Correct. | SQL |
{{'age':86, 'status' 5}} | {{'age':86, 'status':5}} | Colon missing. | Python |
def compute(foo):
return foo + 1 | def compute(foo):
return foo + 1 | Correct. | Python |
int bar = 'result'; | String bar = 'result'; | Type mismatch. | Dart |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
print('message') | print('message') | Correct. | R |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
String y = 'data'; | String y = "data"; | Double quotes. | Java |
var x int | var x int | Correct. | Go |
var x = 87; | var x = 87; | Correct. | Dart |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
if ($foo = 14) | if ($foo == 14) | Use ==. | Perl |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<person age=20> | <person age="20"> | Quote attribute. | XML |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function baz(index:string){{return index;}} baz(43); | function baz(index:string){{return index;}} baz('value'); | Pass correct type. | TypeScript |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:39}}; | Add missing property. | TypeScript |
function baz() {{
return
{{key:'value'}}
}} | function baz() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
data(84) | if length(data) >= 84, data(84), end | Check length. | MATLAB |
local val = 53 | local val = 53 | Correct. | Lua |
if (data = 8) {} | if (data == 8) {} | Use ==. | Dart |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
87num = 10 | num87 = 10 | Variable cannot start with digit. | Python |
for (c in items) | for (c of items) | for...in iterates keys. | JavaScript |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
SELECT * FROM products WHRE status=2; | SELECT * FROM products WHERE status=2; | Fix WHERE. | SQL |
data[22] | if (data.indices.contains(22)) data[22] | Check index. | Kotlin |
if (foo = 21) | if (foo == 21) | Use ==. | Scala |
let mut num=16; let r1=&mut num; let ref2=&mut num; | let mut num=16; {{ let r1=&mut num; }} let ref2=&mut num; | Only one mutable borrow. | Rust |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
let bar: number | null = null; bar.toFixed(34); | let bar: number | null = null; if(bar!==null) bar.toFixed(34); | Null check. | TypeScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
val foo: Int = 'data' | val foo: String = 'data' | Fix type. | Kotlin |
if (bar = 95) {{}} | if (bar === 95) {{}} | Use === for equality. | JavaScript |
class Order {{ int foo; }}; | class Order {{ public: int foo; }}; | Make public. | C++ |
def baz
puts 'message'
end | def baz
puts 'message'
end | Correct. | Ruby |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
b = 21 | b=21 | No spaces. | Shell |
function baz(foo)
print(foo)
end | function baz(foo)
print(foo)
end | Correct. | Lua |
const x = 47; x = 35; | let x = 47; x = 35; | Cannot reassign const. | JavaScript |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(9); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(9); | Correct. | Node.js |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
function process(): void {{ return 42; }} | function process(): number {{ return 42; }} | Return type mismatch. | TypeScript |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
'value' + 75 | 'value' + str(75) | Can't add int to string. | Python |
let val = 70; | let val = 70; | Correct. | JavaScript |
let result: i32 = "result"; | let result: &str = "result"; | Type mismatch. | Rust |
{{"value":"hello" "title":69}} | {{"value":"hello", "title":69}} | Add comma. | JSON |
{{"id":"world",}} | {{"id":"world"}} | Remove trailing comma. | JSON |
<p>message <b>hello</p></b> | <p>message <b>hello</b></p> | Nest properly. | HTML |
if y = 17 | if y == 17 | Use ==. | Ruby |
let vec=vec![79,40,92]; let head=&vec[0]; vec.push(14); | let mut vec=vec![79,40,92]; let head=vec[0]; vec.push(14); | Copy instead of reference. | Rust |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
let b: Int = 'world' | let b: String = 'world' | Fix type. | Swift |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
disp('result') | disp('result') | Correct. | MATLAB |
function bar() {{ echo 'hello'; }} | function bar() {{ echo 'hello'; }} | Correct. | PHP |
object Item {{ def main(args: Array[String]) = println("info") }} | object Item {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
for count in range(21)
print(count) | for count in range(21):
print(count) | Colon after for. | Python |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
<hr></hr> | <hr> | Self-closing. | HTML |
if (c = 91) {{}} | if (c == 91) {{}} | Use ==. | Kotlin |
data[87] | if data.indices.contains(87) {{ data[87] }} | Check index. | Swift |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
if (z = 63) {{}} | if (z == 63) {{}} | Use ==. | Java |
$list[59] = 5; | if (isset($list[59])) $list[59] = 5; | Check existence. | PHP |
if a > 7
puts 'value' | if a > 7
puts 'value'
end | Add 'end'. | Ruby |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
item == '38' | item === 38 | Use strict equality. | JavaScript |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
DELETE FROM items WHERE status=59 | DELETE FROM items WHERE status=59; | Add semicolon. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
name: value
age: 85 | name: value
age: 85 | Correct. | YAML |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
List(81,33,62) | List(81,33,62) | Correct. | Scala |
x := 49 | x := 49 | Correct. | Go |
let z = 98; z += 1; | let mut z = 98; z += 1; | Need mut to modify. | Rust |
val = output | val = 'output' | Quote strings. | Python |
if z > 27
print('result') | if z > 27:
print('result') | Colon missing after if. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(27); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(27, () => console.log('listening')); | Add callback. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.