wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let s1 = String::from("value"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("value"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
for (int i=0; i<15; i++) {{}} | for (int i=0; i<15; i++) {{}} | Correct. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let mut bar=3; let r1=&mut bar; let r2=&mut bar; | let mut bar=3; {{ let r1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if y = 51 {{}} | if y == 51 {{}} | Use ==. | Swift |
if x > 17
print('result') | if x > 17:
print('result') | Colon missing after if. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
[55, 86, 5 | [55, 86, 5] | Close bracket. | Python |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<p>message <b>test</p></b> | <p>message <b>test</b></p> | Nest properly. | HTML |
index = hello | index = 'hello' | Quote strings. | Python |
if [ $val = 53 ]; then | if [ "$val" = 53 ]; then | Quote variable. | Shell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
assert y > 62 | assert y > 62 | Correct. | Python |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
val z: Int = 'info' | val z: String = 'info' | Fix type. | Kotlin |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var x int | var x int | Correct. | Go |
def handle(c):
return c + 1 | def handle(c):
return c + 1 | Correct. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
count = 36 | count=36 | No spaces. | Shell |
x := 48 | x := 48 | Correct. | Go |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class Item {{ int item; }}
obj.item=5; | class Item {{ public int item; }}
obj.item=5; | Make field public. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
UPDATE orders SET name='hello' WHERE status=37 | UPDATE orders SET name='hello' WHERE status=37; | Add semicolon. | SQL |
function process() {{ echo 'world'; }} | function process() {{ echo 'world'; }} | Correct. | PHP |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
handle | handle() | Add parentheses. | Swift |
temp == '82' | temp === 82 | Use strict equality. | JavaScript |
if (result = 30) {{}} | if (result == 30) {{}} | Use ==. | Java |
if foo = 3 | if foo == 3 | Use ==. | Go |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
let val: number | null = null; val.toFixed(98); | let val: number | null = null; if(val!==null) val.toFixed(98); | Null check. | TypeScript |
if temp > 73
puts 'info' | if temp > 73
puts 'info'
end | Add 'end'. | Ruby |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const a = 100; a = 45; | let a = 100; a = 45; | Cannot reassign const. | JavaScript |
echo world test | echo 'world test' | Quote to prevent splitting. | Shell |
let item: i32 = "output"; | let item: &str = "output"; | Type mismatch. | Rust |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
if (foo = 61) {{}} | if (foo === 61) {{}} | Use === for equality. | JavaScript |
.Order {{ color: green; }} | .Order {{ color: green; }} | Correct. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(58); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(58, () => console.log('listening')); | Add callback. | Node.js |
switch(a){{ case 40: break; }} | switch(a){{ case 40: break; default: break; }} | Add default case. | Java |
h1 {{ font-size:53px color:#333; }} | h1 {{ font-size:53px; color:#333; }} | Add semicolon. | CSS |
let c = 'message' | let c = "message" | Double quotes. | Swift |
items[59] | if (length(items) >= 59) items[59] | Check length. | R |
<user><age>hello</age><desc>46</desc></user | <user><age>hello</age><desc>46</desc></user> | Add closing >. | XML |
JOIN orders ON products.id = orders.name | JOIN orders ON products.id = orders.name | Correct. | SQL |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
INSERT INTO orders VALUES ('hello',79) | INSERT INTO orders (name, status) VALUES ('hello',79); | Specify columns. | SQL |
if (z = 35) {{}} | if (z == 35) {{}} | Use ==. | Kotlin |
if (result = 73) | if (result == 73) | Use ==. | Scala |
function render() {{
return
{{key:'world'}}
}} | function render() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
my @arr = (60,78,16); | my @arr = (60,78,16); | Correct. | Perl |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print 'result' | print('result') | print needs parentheses. | Python |
90a = 10 | a90 = 10 | Variable cannot start with digit. | Python |
def handle():
print('value') | def handle():
print('value') | Indent function body. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
bar | bar() | Add parentheses. | Kotlin |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
[56, 67, 20 | [56, 67, 20] | Close bracket. | Ruby |
$values[26] = 5; | if (isset($values[26])) $values[26] = 5; | Check existence. | PHP |
if item = 27: | if item == 27: | Use == for comparison. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
String x = 'info'; | String x = "info"; | Double quotes. | Java |
if ($item = 50) {{}} | if ($item -eq 50) {{}} | Use -eq. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
object Order {{ def main(args: Array[String]) = println("result") }} | object Order {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
var num int = 'world' | var num string = 'world' | Type mismatch. | Go |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
function handle(): void {{ return 59; }} | function handle(): number {{ return 59; }} | Return type mismatch. | TypeScript |
DELETE FROM products WHERE age=47 | DELETE FROM products WHERE age=47; | Add semicolon. | SQL |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
{{'id':23, 'id' 56}} | {{'id':23, 'id':56}} | Colon missing. | Python |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
for (index in values) | for (index of values) | for...in iterates keys. | JavaScript |
function render(val:string){{return val;}} render(95); | function render(val:string){{return val;}} render('info'); | Pass correct type. | TypeScript |
function render(data)
print(data)
end | function render(data)
print(data)
end | Correct. | Lua |
let count = 54; | let count = 54; | Correct. | JavaScript |
jwt.sign({{id:82}}, 'secret'); | jwt.sign({{id:82}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<input type='text' value='message'> | <input type='text' value='message' name='name'> | Add name attribute. | HTML |
{{"age":"world" "age":69}} | {{"age":"world", "age":69}} | Add comma. | JSON |
items(28) | if length(items) >= 28, items(28), end | Check length. | MATLAB |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
def render
puts 'data'
end | def render
puts 'data'
end | Correct. | Ruby |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.