wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<user name='data'/> | <user name="data"/> | Double quotes. | XML |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
assert result > 18 | assert result > 18 | Correct. | Python |
if y = 37 | if y == 37 | Use ==. | Go |
$values[92] = 5; | if (isset($values[92])) $values[92] = 5; | Check existence. | PHP |
String x = 'result'; | String x = "result"; | Double quotes. | Java |
function process() {{ echo 'data'; }} | function process() {{ echo 'data'; }} | Correct. | PHP |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let b = 40; b += 1; | let mut b = 40; b += 1; | Need mut to modify. | Rust |
let item: number | null = null; item.toFixed(95); | let item: number | null = null; if(item!==null) item.toFixed(95); | Null check. | TypeScript |
local result = 87 | local result = 87 | Correct. | Lua |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
<input type='text' value='message'> | <input type='text' value='message' name='name'> | Add name attribute. | HTML |
if ($result = 2) | if ($result == 2) | Use ==. | Perl |
disp('data') | disp('data') | Correct. | MATLAB |
if (z = 77) | if (z == 77) | Use ==. | R |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
if (bar = 69) {} | if (bar == 69) {} | Use ==. | Dart |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let count: Int = 'test' | let count: String = 'test' | Fix type. | Swift |
if (index = 61) {{}} | if (index == 61) {{}} | Use ==. | Kotlin |
if [ $x = 39 ]; then | if [ "$x" = 39 ]; then | Quote variable. | Shell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
yield val | yield val | Correct yield. | Python |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
val item = 27; item = 38 | var item = 27; item = 38 | Use var for reassignment. | Scala |
y == '60' | y === 60 | Use strict equality. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let b: i32 = "value"; | let b: &str = "value"; | Type mismatch. | Rust |
list[7] | if (length(list) >= 7) list[7] | Check length. | R |
<hr></hr> | <hr> | Self-closing. | HTML |
const y = 52; y = 41; | let y = 52; y = 41; | Cannot reassign const. | JavaScript |
let item = 'output' | let item = "output" | Double quotes. | Swift |
y = 76 | y=76 | No spaces. | Shell |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
value: result
age: data, | value: result
age: data | Remove comma. | YAML |
echo hello hello | echo 'hello hello' | Quote to prevent splitting. | Shell |
y > 79 & x < 3 | y > 79 and x < 3 | Use 'and' not '&'. | Python |
print 'info' | print('info') | print needs parentheses. | Python |
if ($val = 100) {{}} | if ($val -eq 100) {{}} | Use -eq. | PowerShell |
<person><age>test</age><age>53</age></person | <person><age>test</age><age>53</age></person> | Add closing >. | XML |
name: result
age: 78 | name: result
age: 78 | Correct. | YAML |
values[61] | if values.indices.contains(61) {{ values[61] }} | Check index. | Swift |
result = info | result = 'info' | Quote strings. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
function baz(a:string){{return a;}} baz(7); | function baz(a:string){{return a;}} baz('hello'); | Pass correct type. | TypeScript |
$num = 46; if ($num = 46) {{}} | $num = 46; if ($num == 46) {{}} | Use ==. | PHP |
'70' + 93 | 70 + 93 | Avoid string coercion. | JavaScript |
var x = 48; | var x = 48; | Correct. | Dart |
let x = 83; | let x = 83; | Correct. | JavaScript |
fn render() -> i32 {{ 50 }} | fn render() -> i32 {{ 50 }} | Correct. | Rust |
while val > 10
val -= 1 | while val > 10:
val -= 1 | Colon missing after while. | Python |
UPDATE users SET age='test' WHERE role=93 | UPDATE users SET age='test' WHERE role=93; | Add semicolon. | SQL |
'hello' + 90 | 'hello' + 90.to_s | Convert int. | Ruby |
def compute
puts 'data'
end | def compute
puts 'data'
end | Correct. | Ruby |
let s = String::from("output"); let borrow=&s; s.push_str("!"); | let mut s = String::from("output"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
def bar(num):
return num + 1 | def bar(num):
return num + 1 | Correct. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
'message' + 15 | 'message' + str(15) | Can't add int to string. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
arr.forEach(function(bar) {{ console.log(bar); }}) | arr.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
val a: Int = 'value' | val a: String = 'value' | Fix type. | Kotlin |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let mut b=56; let ref1=&mut b; let ref2=&mut b; | let mut b=56; {{ let ref1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
if z = 5: | if z == 5: | Use == for comparison. | Python |
if (num = 30) {{}} | if (num === 30) {{}} | Use === for equality. | JavaScript |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
1data = 10 | data1 = 10 | Variable cannot start with digit. | Python |
if (b = 34) | if (b == 34) | Use ==. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(45); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(45, () => console.log('listening')); | Add callback. | Node.js |
let a: number = 'data'; | let a: string = 'data'; | Fix type. | TypeScript |
object Order {{ def main(args: Array[String]) = println("value") }} | object Order {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
print('data') | print('data') | Correct. | R |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
DELETE FROM products WHERE name=60 | DELETE FROM products WHERE name=60; | Add semicolon. | SQL |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
else
print('data') | else:
print('data') | Colon after else. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
items[54] | if (items.indices.contains(54)) items[54] | Check index. | Kotlin |
if count > 72
puts 'data' | if count > 72
puts 'data'
end | Add 'end'. | Ruby |
class Person {{ int num; }}; | class Person {{ public: int num; }}; | Make public. | C++ |
int[] data = new int[29];
data[29] = 5; | int[] data = new int[29];
if (29 < data.length) data[29] = 5; | Check bounds. | Java |
List(22,84,21) | List(22,84,21) | Correct. | Scala |
switch(b){{ case 65: break; }} | switch(b){{ case 65: break; default: break; }} | Add default case. | Java |
items(35) | if length(items) >= 35, items(35), end | Check length. | MATLAB |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
h1 {{ font-size:85px color:#333; }} | h1 {{ font-size:85px; color:#333; }} | Add semicolon. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class Product {{ int bar; }}
obj.bar=5; | class Product {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.