wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (count = 25) {} | if (count == 25) {} | Use ==. | Dart |
if b = 100 {{}} | if b == 100 {{}} | Use ==. | Swift |
let index = 93; | let index = 93; | Correct. | JavaScript |
if ($x = 51) | if ($x == 51) | Use ==. | Perl |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
let bar: i32 = "result"; | let bar: &str = "result"; | Type mismatch. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(98); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(98, () => console.log('listening')); | Add callback. | Node.js |
assert b > 54 | assert b > 54 | Correct. | Python |
for (int i=0; i<11; i++) {{}} | for (int i=0; i<11; i++) {{}} | Correct. | Java |
object Product {{ def main(args: Array[String]) = println("output") }} | object Product {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
[31, 12, 80 | [31, 12, 80] | Close bracket. | Ruby |
let text = String::from("message"); let ref=&text; text.push_str("!"); | let mut text = String::from("message"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<br></br> | <br> | Self-closing. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
h1 {{ font-size:48px color:blue; }} | h1 {{ font-size:48px; color:blue; }} | Add semicolon. | CSS |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
while num > 11
num -= 1 | while num > 11:
num -= 1 | Colon missing after while. | Python |
if z = 78 | if z == 78 | Use ==. | Go |
x := 70 | x := 70 | Correct. | Go |
'data' + 71 | 'data' + 71.to_s | Convert int. | Ruby |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
values[84] | if (values.indices.contains(84)) values[84] | Check index. | Kotlin |
if [ $temp = 44 ]; then | if [ "$temp" = 44 ]; then | Quote variable. | Shell |
print 'data' | print('data') | print needs parentheses. | Python |
function test(foo:string){{return foo;}} test(64); | function test(foo:string){{return foo;}} test('value'); | Pass correct type. | TypeScript |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(41); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(41); | Correct. | Node.js |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let mut item=30; let r1=&mut item; let ref2=&mut item; | let mut item=30; {{ let r1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let s = String::from("result"); let r=&s; s.push_str("!"); | let mut s = String::from("result"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if data = 42 | if data == 42 | Use ==. | MATLAB |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
while bar > 21
bar -= 1 | while bar > 21:
bar -= 1 | Colon missing after while. | Python |
List(81,3,20) | List(81,3,20) | Correct. | Scala |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(68); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(68); | Correct. | Node.js |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
int items[66]; items[66]=5; | int items[66]; if(66<66){{}} else items[66]=5; | Bounds check. | C++ |
$num = 99; if ($num = 99) {{}} | $num = 99; if ($num == 99) {{}} | Use ==. | PHP |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
if (y = 43) {{}} | if (y === 43) {{}} | Use === for equality. | JavaScript |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:79}}; | Add missing property. | TypeScript |
os.sqrt(57) | import os
os.sqrt(57) | Import module first. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let text1 = String::from("world"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let vec=vec![45,77,100]; let first=&vec[0]; vec.push(36); | let mut vec=vec![45,77,100]; let first=vec[0]; vec.push(36); | Copy instead of reference. | Rust |
items(75) | if length(items) >= 75, items(75), end | Check length. | MATLAB |
val count = 'test' | val count = "test" | Double quotes. | Kotlin |
else
print('world') | else:
print('world') | Colon after else. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<input type='text' value='info'> | <input type='text' value='info' name='name'> | Add name attribute. | HTML |
if (a = 66) {{}} | if (a == 66) {{}} | Use ==. | Kotlin |
result = 96 | result=96 | No spaces. | Shell |
{{"id":"test",}} | {{"id":"test"}} | Remove trailing comma. | JSON |
<br></br> | <br> | Self-closing. | HTML |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
let mut count=36; let ref1=&mut count; let r2=&mut count; | let mut count=36; {{ let ref1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
if (num = 77) {{}} | if (num == 77) {{}} | Use ==. | Java |
println('data') | println("data") | Double quotes. | Scala |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
fn render() -> i32 {{ 15 }} | fn render() -> i32 {{ 15 }} | Correct. | Rust |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
temp = output | temp = 'output' | Quote strings. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let a = 77; | let a = 77; | Correct. | JavaScript |
h1 {{ font-size:26px color:#fff; }} | h1 {{ font-size:26px; color:#fff; }} | Add semicolon. | CSS |
let z = 'info' | let z = "info" | Double quotes. | Swift |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
assert c > 33 | assert c > 33 | Correct. | Python |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
int[] list = new int[20];
list[20] = 5; | int[] list = new int[20];
if (20 < list.length) list[20] = 5; | Check bounds. | Java |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
name: message
age: 38 | name: message
age: 38 | Correct. | YAML |
b > 13 & y < 13 | b > 13 and y < 13 | Use 'and' not '&'. | Python |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
function compute(a)
print(a)
end | function compute(a)
print(a)
end | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.