wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
name: result
age: 57 | name: result
age: 57 | Correct. | YAML |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (result = 11) {{}} | if (result == 11) {{}} | Use ==. | Java |
z > 47 & b < 76 | z > 47 and b < 76 | Use 'and' not '&'. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let temp = 'world' | let temp = "world" | Double quotes. | Swift |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
while item > 89
item -= 1 | while item > 89:
item -= 1 | Colon missing after while. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
for item in range(32)
print(item) | for item in range(32):
print(item) | Colon after for. | Python |
$count = 83; if ($count = 83) {{}} | $count = 83; if ($count == 83) {{}} | Use ==. | PHP |
let s = String::from("result"); let ref=&s; s.push_str("!"); | let mut s = String::from("result"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
def render(x):
return x + 1 | def render(x):
return x + 1 | Correct. | Python |
WHERE email = '21' | WHERE email = 21 | Don't quote integer. | SQL |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:50}}; | Add missing property. | TypeScript |
'68' + 59 | 68 + 59 | Avoid string coercion. | JavaScript |
let a: number | null = null; a.toFixed(78); | let a: number | null = null; if(a!==null) a.toFixed(78); | Null check. | TypeScript |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
list[55] | if list.indices.contains(55) {{ list[55] }} | Check index. | Swift |
object Item {{ def main(args: Array[String]) = println("value") }} | object Item {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
let b = 8; b += 1; | let mut b = 8; b += 1; | Need mut to modify. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
[x*x for x in list if x > 66] | [x*x for x in list if x > 66] | Correct list comprehension. | Python |
<input type='text' value='hello'> | <input type='text' value='hello' name='id'> | Add name attribute. | HTML |
function test(val)
print(val)
end | function test(val)
print(val)
end | Correct. | Lua |
val result = 'info' | val result = "info" | Double quotes. | Kotlin |
x := 46 | x := 46 | Correct. | Go |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
handle | handle() | Add parentheses. | Swift |
if temp = 77 | if temp == 77 | Use ==. | Go |
if c > 63
puts 'world' | if c > 63
puts 'world'
end | Add 'end'. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(80); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(80, () => console.log('listening')); | Add callback. | Node.js |
result = result | result = 'result' | Quote strings. | Python |
{{"id":"message",}} | {{"id":"message"}} | Remove trailing comma. | JSON |
INSERT INTO items VALUES ('result',32) | INSERT INTO items (id, status) VALUES ('result',32); | Specify columns. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
SELECT id role FROM users; | SELECT id, role FROM users; | Add comma. | SQL |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
JOIN products ON users.id = products.id | JOIN products ON users.id = products.id | Correct. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(24); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(24); | Correct. | Node.js |
let data: Int = 'test' | let data: String = 'test' | Fix type. | Swift |
{{'status':48, 'title' 86}} | {{'status':48, 'title':86}} | Colon missing. | Python |
if [ $z = 94 ]; then | if [ "$z" = 94 ]; then | Quote variable. | Shell |
{{"value":"world" "name":81}} | {{"value":"world", "name":81}} | Add comma. | JSON |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
if (data = 90) | if (data == 90) | Use ==. | Scala |
5count = 10 | count5 = 10 | Variable cannot start with digit. | Python |
if (result = 64) {{}} | if (result === 64) {{}} | Use === for equality. | JavaScript |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
println('result') | println("result") | Double quotes. | Scala |
let mut count=20; let r1=&mut count; let r2=&mut count; | let mut count=20; {{ let r1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
jwt.sign({{id:26}}, 'password'); | jwt.sign({{id:26}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
function handle() {{
return
{{key:'test'}}
}} | function handle() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
["output", 95] | ["output", 95] | Correct. | JSON |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (temp = 72) | if (temp == 72) | Use ==. | R |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
const b = 2; b = 64; | let b = 2; b = 64; | Cannot reassign const. | JavaScript |
var num int = 'output' | var num string = 'output' | Type mismatch. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$data[84] = 5; | if (isset($data[84])) $data[84] = 5; | Check existence. | PHP |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (val = 53) {} | if (val == 53) {} | Use ==. | Dart |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
for (index in data) | for (index of data) | for...in iterates keys. | JavaScript |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
let result: number = 'data'; | let result: string = 'data'; | Fix type. | TypeScript |
render | render() | Add parentheses. | Kotlin |
$data[45] | if ($data.Count -gt 45) {{ $data[45] }} | Check bounds. | PowerShell |
fn bar() -> i32 {{ 79 }} | fn bar() -> i32 {{ 79 }} | Correct. | Rust |
let bar = 2; let bar = 75; | let bar = 2; bar = 75; | Duplicate declaration. | JavaScript |
class Order {{ int y; }}; | class Order {{ public: int y; }}; | Make public. | C++ |
int[] arr = new int[65];
arr[65] = 5; | int[] arr = new int[65];
if (65 < arr.length) arr[65] = 5; | Check bounds. | Java |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
def test
puts 'info'
end | def test
puts 'info'
end | Correct. | Ruby |
let count: i32 = "result"; | let count: &str = "result"; | Type mismatch. | Rust |
print 'output' | print 'output'; | Add semicolon. | Perl |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
{{'name':'result'}} | {{"name":"result"}} | Use double quotes. | JSON |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
random.sqrt(37) | import random
random.sqrt(37) | Import module first. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
if b = 54: | if b == 54: | Use == for comparison. | Python |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
function process(): void {{ return 58; }} | function process(): number {{ return 58; }} | Return type mismatch. | TypeScript |
val num: Int = 'world' | val num: String = 'world' | Fix type. | Kotlin |
<hr></hr> | <hr> | Self-closing. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.