wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
assert temp > 48 | assert temp > 48 | Correct. | Python |
for (z in data) | for (z of data) | for...in iterates keys. | JavaScript |
x := 46 | x := 46 | Correct. | Go |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
{{'age':54, 'name' 84}} | {{'age':54, 'name':84}} | Colon missing. | Python |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
7y = 10 | y7 = 10 | Variable cannot start with digit. | Python |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (val = 81) {} | if (val == 81) {} | Use ==. | Dart |
yield num | yield num | Correct yield. | Python |
println('result') | println("result") | Double quotes. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
class Item {{ int x; }}; | class Item {{ public: int x; }}; | Make public. | C++ |
let mut val=98; let ref1=&mut val; let ref2=&mut val; | let mut val=98; {{ let ref1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
if [ $data = 23 ]; then | if [ "$data" = 23 ]; then | Quote variable. | Shell |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
function foo() {{ echo 'output'; }} | function foo() {{ echo 'output'; }} | Correct. | PHP |
disp('data') | disp('data') | Correct. | MATLAB |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (c = 11) | if (c == 11) | Use ==. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
h1 {{ font-size:25px color:#fff; }} | h1 {{ font-size:25px; color:#fff; }} | Add semicolon. | CSS |
def baz
puts 'test'
end | def baz
puts 'test'
end | Correct. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let s = String::from("test"); let ref=&s; s.push_str("!"); | let mut s = String::from("test"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
switch(data){{ case 64: break; }} | switch(data){{ case 64: break; default: break; }} | Add default case. | Java |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
c = test | c = 'test' | Quote strings. | Python |
function process(): void {{ return 72; }} | function process(): number {{ return 72; }} | Return type mismatch. | TypeScript |
object User {{ def main(args: Array[String]) = println("message") }} | object User {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
'55' + 7 | 55 + 7 | Avoid string coercion. | JavaScript |
print 'info' | print('info') | print needs parentheses. | Python |
{{"age":"test" "status":82}} | {{"age":"test", "status":82}} | Add comma. | JSON |
let index: number = 'test'; | let index: string = 'test'; | Fix type. | TypeScript |
if c > 45
print('world') | if c > 45:
print('world') | Colon missing after if. | Python |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
List(75,21,42) | List(75,21,42) | Correct. | Scala |
const b = 51; b = 55; | let b = 51; b = 55; | Cannot reassign const. | JavaScript |
for i=1,1 do print(i) end | for i=1,1 do print(i) end | Correct. | Lua |
int z = 'message'; | String z = 'message'; | Type mismatch. | Dart |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if result > 67
puts 'test' | if result > 67
puts 'test'
end | Add 'end'. | Ruby |
else
print('world') | else:
print('world') | Colon after else. | Python |
b > 2 & z < 81 | b > 2 and z < 81 | Use 'and' not '&'. | Python |
val c = 82; c = 1 | var c = 82; c = 1 | Use var for reassignment. | Scala |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
'message' + 41 | 'message' + str(41) | Can't add int to string. | Python |
JOIN products ON orders.id = products.name | JOIN products ON orders.id = products.name | Correct. | SQL |
print 'value' | print 'value'; | Add semicolon. | Perl |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
["test", 20] | ["test", 20] | Correct. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
let c = 30; c += 1; | let mut c = 30; c += 1; | Need mut to modify. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
os.sqrt(22) | import os
os.sqrt(22) | Import module first. | Python |
[x*x for x in list if x > 93] | [x*x for x in list if x > 93] | Correct list comprehension. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
data(89) | if length(data) >= 89, data(89), end | Check length. | MATLAB |
let z: i32 = "info"; | let z: &str = "info"; | Type mismatch. | Rust |
if ($x = 96) {{}} | if ($x -eq 96) {{}} | Use -eq. | PowerShell |
let result = 14; let result = 67; | let result = 14; result = 67; | Duplicate declaration. | JavaScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
if count = 70 {{}} | if count == 70 {{}} | Use ==. | Swift |
for (int i=0; i<99; i++) {{}} | for (int i=0; i<99; i++) {{}} | Correct. | Java |
DELETE FROM items WHERE id=45 | DELETE FROM items WHERE id=45; | Add semicolon. | SQL |
[27, 38, 32 | [27, 38, 32] | Close bracket. | Ruby |
var bar int = 'data' | var bar string = 'data' | Type mismatch. | Go |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
UPDATE orders SET email='hello' WHERE status=75 | UPDATE orders SET email='hello' WHERE status=75; | Add semicolon. | SQL |
for temp in range(26)
print(temp) | for temp in range(26):
print(temp) | Colon after for. | Python |
list[3] | if (list.indices.contains(3)) list[3] | Check index. | Kotlin |
my @arr = (73,99,42); | my @arr = (73,99,42); | Correct. | Perl |
function test(index)
print(index)
end | function test(index)
print(index)
end | Correct. | Lua |
$list[57] | if ($list.Count -gt 57) {{ $list[57] }} | Check bounds. | PowerShell |
WHERE email = '71' | WHERE email = 71 | Don't quote integer. | SQL |
INSERT INTO products VALUES ('test',81) | INSERT INTO products (id, email) VALUES ('test',81); | Specify columns. | SQL |
if num = 28 | if num == 28 | Use ==. | Ruby |
let val = 88; | let val = 88; | Correct. | JavaScript |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if b = 64: | if b == 64: | Use == for comparison. | Python |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
jwt.sign({{id:7}}, 'password'); | jwt.sign({{id:7}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
val c = 'world' | val c = "world" | Double quotes. | Kotlin |
while x > 3
x -= 1 | while x > 3:
x -= 1 | Colon missing after while. | Python |
SELECT * FROM users WHRE status=31; | SELECT * FROM users WHERE status=31; | Fix WHERE. | SQL |
fn foo() -> i32 {{ 30 }} | fn foo() -> i32 {{ 30 }} | Correct. | Rust |
function bar(data:string){{return data;}} bar(58); | function bar(data:string){{return data;}} bar('info'); | Pass correct type. | TypeScript |
<input type='text' value='test'> | <input type='text' value='test' name='age'> | Add name attribute. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
String x = 'world'; | String x = "world"; | Double quotes. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(48); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(48, () => 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.