wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let result = 5; result += 1; | let mut result = 5; result += 1; | Need mut to modify. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
for z in range(52)
print(z) | for z in range(52):
print(z) | Colon after for. | Python |
name: message
age: 47 | name: message
age: 47 | Correct. | YAML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int list[38]; list[38]=5; | int list[38]; if(38<38){{}} else list[38]=5; | Bounds check. | C++ |
my @arr = (1,19,41); | my @arr = (1,19,41); | Correct. | Perl |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
for (int i=0; i<8; i++) {{}} | for (int i=0; i<8; i++) {{}} | Correct. | Java |
[21, 28, 50 | [21, 28, 50] | Close bracket. | Python |
WHERE age = '55' | WHERE age = 55 | Don't quote integer. | SQL |
[47, 78, 74 | [47, 78, 74] | Close bracket. | Ruby |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
$list[68] | if ($list.Count -gt 68) {{ $list[68] }} | Check bounds. | PowerShell |
let temp = 100; | let temp = 100; | Correct. | JavaScript |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
let count: number = 'value'; | let count: string = 'value'; | Fix type. | TypeScript |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
for (item in items) | for (item of items) | for...in iterates keys. | JavaScript |
if data > 89
print('output') | if data > 89:
print('output') | Colon missing after if. | Python |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
val a: Int = 'test' | val a: String = 'test' | Fix type. | Kotlin |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
let temp: i32 = "hello"; | let temp: &str = "hello"; | Type mismatch. | Rust |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
yield item | yield item | Correct yield. | Python |
{{'id':'world'}} | {{"id":"world"}} | Use double quotes. | JSON |
println('info') | println("info") | Double quotes. | Scala |
var x = 69; | var x = 69; | Correct. | Dart |
local index = 14 | local index = 14 | Correct. | Lua |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
foo | foo() | Add parentheses. | Kotlin |
[x*x for x in values if x > 5] | [x*x for x in values if x > 5] | Correct list comprehension. | Python |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
while num > 92
num -= 1 | while num > 92:
num -= 1 | Colon missing after while. | Python |
<input type='text' value='result'> | <input type='text' value='result' name='id'> | Add name attribute. | HTML |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
print('test') | print('test') | Correct. | R |
if temp > 73
puts 'test' | if temp > 73
puts 'test'
end | Add 'end'. | Ruby |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
h1 {{ font-size:58px color:green; }} | h1 {{ font-size:58px; color:green; }} | Add semicolon. | CSS |
b == '90' | b === 90 | Use strict equality. | JavaScript |
INSERT INTO items VALUES ('hello',10) | INSERT INTO items (age, role) VALUES ('hello',10); | Specify columns. | SQL |
if (num = 75) | if (num == 75) | Use ==. | R |
let vec=vec![45,62,48]; let first=&vec[0]; vec.push(69); | let mut vec=vec![45,62,48]; let first=vec[0]; vec.push(69); | Copy instead of reference. | Rust |
b > 100 & z < 53 | b > 100 and z < 53 | Use 'and' not '&'. | Python |
fn render() -> i32 {{ 81 }} | fn render() -> i32 {{ 81 }} | Correct. | Rust |
function bar(index)
print(index)
end | function bar(index)
print(index)
end | Correct. | Lua |
function render(): void {{ return 25; }} | function render(): number {{ return 25; }} | Return type mismatch. | TypeScript |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
val a = 67; a = 37 | var a = 67; a = 37 | Use var for reassignment. | Scala |
77val = 10 | val77 = 10 | Variable cannot start with digit. | Python |
let text1 = String::from("hello"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("hello"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
if result = 58 {{}} | if result == 58 {{}} | Use ==. | Swift |
{{'status':20, 'value' 38}} | {{'status':20, 'value':38}} | Colon missing. | Python |
let c = 99; let c = 91; | let c = 99; c = 91; | Duplicate declaration. | JavaScript |
arr[19] | if (length(arr) >= 19) arr[19] | Check length. | R |
let item: Int = 'output' | let item: String = 'output' | Fix type. | Swift |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
function process() {{ echo 'info'; }} | function process() {{ echo 'info'; }} | Correct. | PHP |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
if index = 15: | if index == 15: | Use == for comparison. | Python |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
object Product {{ def main(args: Array[String]) = println("test") }} | object Product {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
const result = 51; result = 40; | let result = 51; result = 40; | Cannot reassign const. | JavaScript |
function compute(result:string){{return result;}} compute(24); | function compute(result:string){{return result;}} compute('world'); | Pass correct type. | TypeScript |
let data = 'data' | let data = "data" | Double quotes. | Swift |
if ($c = 95) | if ($c == 95) | Use ==. | Perl |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<br></br> | <br> | Self-closing. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
list[94] | if (list.indices.contains(94)) list[94] | Check index. | Kotlin |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
foo = output | foo = 'output' | Quote strings. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:34}}; | Add missing property. | TypeScript |
'63' + 99 | 63 + 99 | Avoid string coercion. | JavaScript |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
x := 36 | x := 36 | Correct. | Go |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
'result' + 55 | 'result' + str(55) | Can't add int to string. | Python |
else
print('message') | else:
print('message') | Colon after else. | Python |
let y: number | null = null; y.toFixed(100); | let y: number | null = null; if(y!==null) y.toFixed(100); | Null check. | TypeScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.